Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Reference

The API reference is generated automatically by rustdoc. The links below point to each crate’s generated documentation:

vgui

The main crate. Key exports:

Macros

MacroSource crateDescription
view!vgui-viewJSX-like view markup.
css!vgui-cssCSS-in-Rust style declarations.
tw!vgui-tailwindTailwind utility class compilation.
variants!vguiComponent variant system (base + dimension styles).
theme!vguiCSS variable theme builder.
twc!vguiDynamic Tailwind class composition at runtime.

Reactivity

ItemDescription
create_signal<T>(initial) -> (ReadSignal<T>, WriteSignal<T>)Creates a reactive signal.
create_memo<T>(f) -> ReadSignal<T>Creates a derived, cached value.
create_effect(f)Creates a side effect that re-runs on dep change.
on_cleanup(f)Registers a cleanup callback that runs on scope disposal.
ReadSignal<T>::get() -> TReads value, registers dependency.
ReadSignal<T>::get_with(cx) -> TReads value without tracking.
WriteSignal<T>::set(cx, value)Sets value, notifies if changed.
WriteSignal<T>::update(cx, f) -> RMutates value in place, notifies if changed. Returns the closure’s result.
create_store<T>(initial) -> (Store<T>, SetStore<T>)Creates a reactive store for aggregate state. T: Clone + 'static (no PartialEq needed).
Store<T>::get() -> TReads whole state, registers dependency.
Store<T>::with(f) -> RBorrows state through a closure, registers dependency.
Store<T>::select(f) -> ReadSignal<U>Derives a fine-grained signal for a slice; only notifies when the slice changes.
SetStore<T>::set(cx, value)Replaces entire state, always notifies.
SetStore<T>::update(cx, f) -> RMutates state in place, always notifies.
next_auto_id() -> u64Stable per-render element id (used by view!).

Mounting

ItemDescription
mount(cx, render_fn) -> Entity<VguiRoot>Creates the root entity and reactive scope.
VguiRootThe gpui entity owning the reactive scope.

Router

ItemDescription
create_router(initial: &str) -> RouterCreates a router backed by a path signal.
Router::navigate(cx, path)Updates the path signal, triggering re-render.
Router::path() -> StringReactive read of current path.
Router::path_with(cx) -> StringNon-tracking read of current path.
Router::path_signal() -> ReadSignal<String>The underlying read signal.
Router::match_route(pattern) -> Option<RouteMatch>Match a single pattern against current path.
Router::render(cx, routes, fallback) -> ERender first matching route from &[(&str, F)].
RouteMatch{ pattern, path, params: HashMap<String, String> }.
match_pattern(pattern, path) -> Option<RouteMatch>Standalone pattern match with :param and * wildcard.
build_path(pattern, params) -> StringSubstitute :param placeholders with values.

See Router for a full guide.

Context

ItemDescription
Context&lt;T&gt;Zero-sized typed marker for a context key.
use_context(&Context&lt;T&gt;) -> Option&lt;T&gt;Read nearest ancestor provider value.
use_context_or(&Context&lt;T&gt;, || T) -> TRead nearest provider, or fallback default.
provide_context(&Context&lt;T&gt;, value) -> ProviderGuardRAII manual provider (pops on drop).
ProviderGuardGuard returned by provide_context.

See Context & Provider for a full guide.

Control flow

ItemDescription
show(when, then, fallback) -> AnyElementConditional render with fallback.
show_when(when, then) -> AnyElementConditional render (no fallback).
for_each(items, child_fn) -> AnyElementList rendering.
for_each_or(items, fallback, child_fn) -> AnyElementList rendering with fallback.
index_list(items, child_fn) -> AnyElementKeyed-by-position list with per-item child scopes.
index_list_or(items, fallback, child_fn) -> AnyElementKeyed-by-position list with fallback.
progress(value, max) -> DivProgress bar.
meter(value, min, max, low, high, optimum) -> DivMeter gauge.
details(open, summary, content) -> AnyElementCollapsible container.

Overlays

ItemDescription
portal(content, priority) -> AnyElementPortal floating layer at a given priority.
dialog(open, on_close, content) -> AnyElementModal dialog with portal, click-outside, escape.
floating(position, content) -> AnyElementPositioned floating element.

Input widgets

ItemDescription
text_input(TextInputProps) -> Entity<TextInput>Text-based input.
text_area(TextAreaProps) -> Entity<TextInput>Multi-line text input.
checkbox(CheckboxProps) -> Stateful<Div>Checkbox widget.
radio(RadioProps) -> Stateful<Div>Radio button widget.
range_input(RangeProps) -> Entity<RangeInput>Range slider.
file_input(FileProps) -> Stateful<Div>File picker button.
select(SelectProps) -> Stateful<Div>Select dropdown.
select_with_options(SelectProps, R) -> Stateful<Div>Select with per-option content renderer closure.
datalistAutocomplete suggestions for text inputs (via <datalist> element).

Props structs

StructFields
TextInputPropskind, multiline, value, placeholder, disabled, readonly, min, max, step, on_input, on_change, style, class, id, tabindex
TextAreaPropsvalue, placeholder, disabled, readonly, on_input, on_change, style, class, id, tabindex
CheckboxPropschecked, disabled, on_change
RadioPropschecked, disabled, on_change
RangePropsvalue, min, max, step, disabled, on_change, style, class, id, tabindex
FilePropsmultiple, on_change
SelectPropsoptions: Vec<(String, String)>, groups: Vec<SelectGroup>, value, multiple, disabled, on_change

Enums

EnumVariants
TextKindText, Password, Search, Email, Url, Tel, Number, Date, DateTime, Time, Month, Week, Color
BreakpointSm, Md, Lg, Xl

Refs

ItemDescription
NodeRef::new()Creates a new NodeRef handle.
NodeRef::focus()Focuses the bound element.
NodeRef::scroll_to_bottom()Scrolls the bound element to the bottom.
NodeRef::bounds()Returns the bounds of the bound element.

See Refs & NodeRef for the full API.

Style types

ItemDescription
CssOutput of css!. Wraps a FnOnce(&mut StyleRefinement).
TwStyleOutput of tw!/twc!. Holds base, hover, focus, active closures.
ApplyStyle&lt;E&gt;Trait for applying a style to an element.
TwClassBuilder for composing Tailwind classes (new(), add(), add_if()).
TwClassSourceTrait implemented for &str, String, Option&lt;T&gt;, TwClass.
IntoTwStyleTrait converting class sources into TwStyle.
tw_dynamic(classes: &str)Runtime Tailwind class interpreter (counterpart to tw!).
TwAnimationAnimation definition type.
TwTransitionTransition definition type.
EasingEasing function enum for animations/transitions.
ThemeCSS variable theme store (built by theme!).
CssValueEnum of CSS value kinds (color, length, number, keyword).
set_theme(theme)Installs a theme into the thread-local store.
with_theme(theme, f)Runs a closure with a temporary theme.
Spread&lt;E&gt;Trait for spreading props onto a built-in element.

Helpers

ItemDescription
click(f)Wraps Fn(&mut App) into a gpui click handler.
into_child(value)Converts any IntoElement (or IntoViewChild) to AnyElement.
input_cb(f)Wraps FnMut(&str, &mut App) for on:input.
str_change_cb(f)Wraps FnMut(&str, &mut App) for on:change (text).
bool_change_cb(f)Wraps FnMut(bool, &mut App) for on:change (checkbox/radio).
f64_change_cb(f)Wraps FnMut(f64, &mut App) for on:change (range).
files_cb(f)Wraps FnMut(Vec<PathBuf>, &mut App) for on:change (file).
str_select_change_cb(f)Wraps FnMut(&str, &mut App) for on:change (select).
intercept_keyboard_events()Installs window-level keyboard event listeners (WASM-only; no-op on native). Required in every WASM start().

Prelude

use vgui::prelude::* brings into scope:

view, css, tw, twc, tw_dynamic, variants, theme, set_theme, with_theme, create_signal, create_memo, create_effect, create_store, create_router, on_cleanup, index_list, index_list_or, enter_child_scope, exit_child_scope, ReadSignal, WriteSignal, Store, SetStore, RouteMatch, Router, Breakpoint, click, mount, Context, use_context, use_context_or, provide_context, NodeRef, KeyboardEvent, PointerEvent, PointerType, ResizeEvent, WheelEvent, checkbox, radio, range_input, file_input, input_cb, bool_change_cb, f64_change_cb, files_cb, CheckboxProps, FileProps, RadioProps, RangeProps, TextInputProps, TextKind, Theme, TwClass, TwClassSource, IntoTwStyle, portal, floating, and all of gpui::prelude::*.

vgui-view

The view! proc-macro crate. No runtime API — the macro expands at compile time.

vgui-css

The css! proc-macro crate. No runtime API — the macro expands at compile time.

vgui-tailwind

The tw! proc-macro crate. No runtime API — the macro expands at compile time.

vgui-tailwind-core

Shared library crate (not a proc-macro) providing the parse logic and class tables used by both tw! (compile-time) and tw_dynamic (runtime). Has no gpui dependency.

Building Locally

The entire documentation site — WASM demos, this mdBook, and the rustdoc API reference — is built with a single command:

scripts/build_docs.sh

The output is written to book/book/. To build and immediately serve it:

scripts/build_docs.sh --serve

The site is then available at http://127.0.0.1:8080.

Prerequisites: mdbook, wasm-bindgen, and the nightly Rust toolchain (the repo pins nightly via rust-toolchain.toml).