gpuicn
Theme

Theme the previews

Every preview on the site is live GPUI and follows these.

Base
Accent
Radius
gpuicn theme set --base-color neutral --radius 0.625rem

Forms

Combobox

An input paired with a searchable list of choices.

Added in 0.2.0 12 lines of Rust

Gallery

Starting the preview. GPUI compiles to WebAssembly, so the first load takes a few seconds. This browser has neither WebGPU nor WebGL 2, so the live preview cannot run. The code on this page still works. The preview did not start.

Installation

After the one-time setup, run the command from your app root. The CLI writes the modules and keeps src/ui/mod.rs in step.

gpuicn add combobox

If you prefer to copy the files by hand, declare them yourself:

// src/ui/mod.rs
pub mod theme;
pub mod input;
pub mod field;
pub mod select;
pub mod combobox;

// src/main.rs
mod ui;

Usage

Put this in a view module and return example(window, cx) from its render method.

use crate::ui::combobox::*;
use crate::ui::select::{SelectItem, SelectState};
use gpui_kit::{App, IntoElement, Window};

fn example(window: &mut Window, cx: &mut App) -> impl IntoElement {
    let state = window.use_keyed_state("fruit", cx, |window, cx| {
        SelectState::new(
            [
                SelectItem::new("apple", "Apple"),
                SelectItem::new("pear", "Pear"),
            ],
            window,
            cx,
        )
    });
    combobox(&state)
        .aria_label("Fruit")
        .placeholder("Choose a fruit…")
}

Examples

Empty

With no value, the placeholder shows. Type to filter the list.

Starting the preview. GPUI compiles to WebAssembly, so the first load takes a few seconds. This browser has neither WebGPU nor WebGL 2, so the live preview cannot run. The code on this page still works. The preview did not start.

Disabled

A disabled combobox shows its value but takes no input.

Starting the preview. GPUI compiles to WebAssembly, so the first load takes a few seconds. This browser has neither WebGPU nor WebGL 2, so the live preview cannot run. The code on this page still works. The preview did not start.

API reference

pub fn combobox(state: &Entity<SelectState>) -> Select

Search the options and commit a listed value; subscribe to the state's change events.

Installed source, 12 lines
//! Editable Nova selection using the shared Kit-backed collection state.
use super::select::{Mode, Select};
pub use super::select::{SelectEvent, SelectItem, SelectState};
use gpui_kit::Entity;

/// Search the options and commit a listed value; subscribe to the state's change events.
pub fn combobox(state: &Entity<SelectState>) -> Select {
    let mut select = Select::new(state);
    select.mode = Mode::Combobox;
    select
}

Platform notes

Visual reference: shadcn/ui 4.19.0, Neutral Nova. Implementation: crates/ui/registry/combobox/combobox.rs, using GPUI Kit 0.6.4.

A retained SelectState owns a Kit text editor and one selected option. The query filters choices. Arrow keys skip disabled options, Enter commits and Escape closes and restores focus. Multiple selection and chips are outside this API.

The Rust source and Usage example define the supported API. Browser DOM/CSS behavior, exact exit animations and cross-platform screen-reader parity are not implied by the native component. See migration qualification for the checks completed on this revision.