Combobox

An input that filters a list of options as you type, for one value or many.

View as Markdown

Installation

Usage

Pass items to Combobox, and render each one from a function in ComboboxList. The list shows only the items that match what's typed.

Composition

Multiple

Add multiple to Combobox and use ComboboxChips in place of ComboboxInput. Each picked value is a ComboboxChip; Backspace in the empty input removes the last one.

Creatable

To let people add values that aren't in the list, add the typed text to items when nothing matches it, and label that item as new. autoHighlight highlights the first match once something is typed, so Enter picks it. A comma, or Enter with nothing highlighted, adds the typed text as a chip.

Opening the list also highlights a picked chip, with the reason "none". Enter on an empty input would remove it, so the handler only lets Enter through for a highlight made by typing, the arrow keys or the pointer. It forgets the highlight when the list closes, so Enter after Escape never submits a surrounding form.

Escape with the list closed clears every chip. To keep them, ignore that change and let Escape reach the parent, so a dialog around the field closes instead:

Clear Button

Add showClear to ComboboxInput to show a button that clears the value. It takes the trigger's place while there's a value.

Groups

Pass groups as items, each with its own items, and render each group's items with ComboboxCollection.

Size

Use the size prop on ComboboxInput or ComboboxChips to match the controls beside it, and on ComboboxContent to size its rows.

Disabled

Add disabled to Combobox to disable it, or to a ComboboxItem to disable one option.

Invalid

Add invalid to the Field, so the input takes the red edge.

Please select a fruit.

API Reference

Every part takes sx, applied last. For the rest, see Base UI Combobox.