gpui-ai

Human in the loop

Form controls

Single-choice groups and toggles in the library's own grammar.

Form controls — gpui-ai

Starts when it scrolls into view

Pop out

NORD FROST · DARK · RADIUS 6/10 · BASE 16PX · SHADOW

Running the real component, compiled to WebAssembly. The frame is 300 px tall, which is what this story measures at the demo width in the default type size — a narrower column or a theme that changes that size will wrap it differently.
Source
form.rs
Story
form-controls
Demo height
300 px
Events
ChoiceEvent, ToggleEvent

Code

Cut from the gallery story this page runs. The states above change what the demo is given rather than how it is built, so they share this code.

crates/gallery/src/gallery.rsOpen in the galleryImplementation
ChoiceGroup::new("flavours", "How many flavours ship first?")
    .options([
        ChoiceOption::new("three", "Three")
            .description("The core line, and the fastest to stock"),
        ChoiceOption::new("five", "Five").description("The full case"),
        ChoiceOption::new("one", "Just one hero"),
        ChoiceOption::new("none", "Undecided").disabled(true),
    ])

Events and ownership

Who owns the state
ChoiceGroup renders state supplied by the application; it does not own durable work.
What it emits
Interactive intent is reported through the typed ChoiceEvent and ToggleEvent contracts and stable application IDs.
What it means
Single-choice groups and toggles in the library's own grammar.
Overflow and motion
Growing content remains reachable in a bounded vertical surface; reduced motion preserves a useful state.

Event types

  • ChoiceEvent
  • ToggleEvent

What the demo does and does not show

The demo above is the same Rust as the native component, compiled to WebAssembly and drawn on a WebGPU canvas — not a mock-up, a recording, or a re-implementation. What it paints is what the component paints: layout, colour from the live theme, and motion.

The live browser specimen requires WebGPU; the native component remains the authoritative runtime.

A canvas cannot stand in for the platform, so treat everything that goes through the operating system as unproven here: keyboard handling and shortcuts, screen reader semantics, text input and IME, the clipboard, file drops, and the frame rate you would get on your own GPU. Judge those in a native build. If your browser has no WebGPU, the frame says so rather than showing an empty box.