Selection Panel

An always-visible option list.

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::selection_panel::{SelectionPanelBuilder, SelectionPanelItem};

struct Example {
    control: gpui::Entity<
        xgpui_luma::controls::selection_panel::SelectionPanelControl<
            xgpui_luma::controls::selection_panel::SelectionPanelItem,
        >,
    >,
    last_action: 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::selection_panel_builder(&look, "actions", [SelectionPanelItem::new("open").label("Open")])
            .on_activate_row(cx, |app, _, _, item_id, cx| {
                app.last_action = item_id.to_string();
                cx.notify();
            })
            .spawn(cx);

        Self { control, last_action: 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

selection_panel_builder(&look, id, items) supplies Radix row/panel chrome and scrollbars for typed SDK items. selection_panel_look(&look, size) is available for direct template composition.

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

Supports active-row, hover, and activation events. It is not the popup Selector.

Relevant contracts: SelectionPanelItemRenderModel, SelectionPanelItemTemplate, SelectionPanelItemTemplateModifier, SelectionPanelTemplateHandlers.

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
HoverChanged { visible_index: Option<usize> }.on_hover_changed(cx, |app, visible_index, cx| { … })
ActivateRow { source_index: usize, visible_index: usize, item_id: SharedString }.on_activate_row(cx, |app, source_index, visible_index, item_id, cx| { … })
ActiveIndexChanged { visible_index: Option<usize> }.on_active_index_changed(cx, |app, visible_index, cx| { … })
FocusChanged { focused: bool }.on_focus_changed(cx, |app, focused, cx| { … })
OpenChanged { open: bool }.on_open_changed(cx, |app, open, cx| { … })

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

Source

SDK module · Radix adapter