ComboBox

An editable query with selectable options.

Try it

Interact with the control below. This preview runs the exact code sample shown on this page.

Open example separately ↗

Basic use

Radix · integration snippet
use xgpui_luma_look_radix as radix;
use gpui::{Context};
use xgpui_luma::controls::combobox::{SelectionItem};

struct Example {
    control: xgpui_luma::controls::combobox::ComboBox,
    query: String,
}

impl Example {
    fn new(cx: &mut Context<Self>) -> Self {
        let look = cx.try_global::<radix::Look>().cloned().unwrap_or_else(radix::Look::built_in);
        let control = radix::combobox_builder(&look, "search", [SelectionItem::new("rust", "Rust")]).on_value_changed(cx, |app, query, cx| {
                app.query = query.to_string();
                cx.notify();
            })
            .spawn(cx);



        Self { control, query: String::new() }
    }
}

Integration snippet, checked against the current SDK and Radix crates. cx is the initialized owner context. The control retains its callbacks; callback owners are held weakly. Render self.control.clone() in the owner’s view.

Radix styling

combobox_builder(&look, id, items) installs Radix text-field, option-panel, and scrollbar styling. Keep SDK typing policies, clear behavior, and custom panel/item templates on the returned builder.

Pass an explicit Look, including forks. Theme adapters retain that binding; notify affected controls and their owners after palette, mode, or stylesheet edits. Resolved look values are snapshots and must be resolved again during render.

See the Radix control support table for adapter and utility status.

SDK behavior & customization

Control, panel, and item templates are separate extension points. Prefer panel_template and with_item_template for new customization.

Relevant contracts: ComboBoxItemRenderModel, ComboBoxItemTemplate, ComboBoxItemTemplateModifier, ComboBoxItemsRenderModel.

Use the module’s template contract for structural changes. Builder modifiers and item templates vary by control.

Events

Callbacks follow the existing SDK event stream. Registrations append, hold the owner weakly, and live until the control is released. cx.notify() requests an owner redraw. Compound payloads are borrowed; scalar values are passed by value.

Event / payloadCallback
Change { query: SharedString }.on_value_changed(cx, |app, query, cx| { … })
Select { item_id: SharedString, label: SharedString }.on_select(cx, |app, item_id, label, cx| { … })
Complete { item_id: SharedString, label: SharedString }.on_complete(cx, |app, item_id, label, cx| { … })
Clear.on_clear(cx, |app, cx| { … })
FocusChanged { focused: bool }.on_focus_changed(cx, |app, focused, cx| { … })
OpenChanged { open: bool }.on_open_changed(cx, |app, open, cx| { … })
Dismiss.on_dismiss(cx, |app, cx| { … })

Use .on_event(cx, |app, event, cx| { … }) for all events. Factory-created controls support the same callbacks through ComboBoxEventExt. Existing cx.subscribe observers remain supported.

Source

SDK module · Radix adapter