Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ComboBox

An input that combines text entry with a filtered popup list of options.

When To Use It

Use ComboBox when users should be able to type to narrow a list before selecting an item. It is useful for medium or large option sets where scanning a full menu is slower than filtering.

Constructing a ComboBox

A ComboBox takes a list signal and a selected index signal.

let options = Signal::new(vec![
	String::from("Apple"),
	String::from("Banana"),
	String::from("Cherry"),
]);
let selected = Signal::new(0usize);

ComboBox::new(cx, options, selected)
	.on_select(|cx, index| cx.emit(AppEvent::SelectOption(index)));

As the user types, ComboBox filters matching options. Enter confirms the highlighted option, Escape closes the popup, and arrow keys change the highlighted row.

ComboBox Modifiers

ModifierTypeDescriptionDefault
on_selectFn(&mut EventContext, usize)Called with the selected source index when an option is chosen.-

Components and Styling

ComboBox is composed from a textbox and a popover list.

SelectorDescription
comboboxRoot ComboBox element.
combobox .titleInternal textbox element used for editing/filtering text.

Popup list content is rendered in a Popover and List while open.

Accessibility

ComboBox builds on Textbox and List interaction patterns.

  • Ensure the control has a visible label, or set an accessible name.
  • Keyboard users can open/type/filter/select without pointer input.

Keyboard interaction:

KeyAction
ArrowDownMove highlight to next filtered option
ArrowUpMove highlight to previous filtered option
EnterSelect highlighted option
EscapeClose popup (or submit existing value when already closed)