Combobox

Comboboxes let users choose an option from a list they can filter by typing into a search field.

The Combobox component is a Base UI component.

The control is a ComboboxTrigger that shows the selected option with ComboboxValue, and the typing field lives inside the popup as ComboboxSearch. Pass the options to the items prop on Combobox and render each one with a ComboboxList render function, so the list is filtered as the user types. ComboboxEmpty renders its children when no options match.

Groups

Use ComboboxGroup with a ComboboxGroupLabel to label related options. Represent the options as an array of group objects with an items property, pass each group's items to its ComboboxGroup, and render the options with ComboboxCollection so filtering keeps working. Groups without a matching option are hidden.

Icons

Options can include an icon before their label and a supporting description. Pass a render function to ComboboxValue to render the selected option's icon and description in the control — like the Select.

Use option objects shaped as { value, label, ... }: the label is automatically used for filtering, and the value for form submission.

Size

The ComboboxTrigger comes with 5 sizes: 32, 36, 40 (default), 44, and 48.

Rounded

Use the rounded prop to give the trigger fully rounded corners.

Disabled

Use the disabled prop on ComboboxItem to prevent a single option from being selected, or the disabled prop on Combobox to disable the entire control.

State

By default, Combobox is an uncontrolled component that manages its own state. Use the defaultValue prop to set the initially selected option.

<Combobox defaultValue="Sans-serif" items={FONTS}>
<ComboboxTrigger>
<ComboboxValue placeholder="Select a font" />
</ComboboxTrigger>
<ComboboxContent>{/* ... */}</ComboboxContent>
</Combobox>

Use value and onValueChange props if you need to access or control the selected option. The text typed into ComboboxSearch can be controlled separately with the inputValue and onInputValueChange props.

const [font, setFont] = useState(null)
return (
<Combobox items={FONTS} onValueChange={setFont} value={font}>
<ComboboxTrigger>
<ComboboxValue placeholder="Select a font" />
</ComboboxTrigger>
<ComboboxContent>{/* ... */}</ComboboxContent>
</Combobox>
)