Search Selector
Search and choose an option.
Try it
Interact with the control below. This preview runs the exact code sample shown on this page.
Basic use
use xgpui_luma_look_radix as radix;
use gpui::{Context};
use xgpui_luma::controls::search_selector::{SelectionItem};
struct Example {
control: xgpui_luma::controls::search_selector::SearchSelector,
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::search_selector_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
search_selector_builder(&look, id, items) shares Radix selector triggers, search fields, option rows, and scrollbars. Configure SDK opening, selection, and wheel policies before spawning.
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 can be customized separately.
Relevant contracts: SearchSelectorItemRenderModel, SearchSelectorItemTemplate, SearchSelectorItemTemplateModifier, SearchSelectorPanelRenderModel.
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 / payload | Callback |
|---|---|
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 SearchSelectorEventExt. Existing cx.subscribe observers remain supported.