Combobox
comboboxA text field that filters a list as you type, with one value chosen from the results. Composable parts, so the field can hold a plain value, an object with a label, or several of either. Filtering, keyboard navigation and the active option being announced all come from Base UI.
"use client";
import { useState } from "react";
import {
Combobox,
ComboboxCollection,
ComboboxContent,
ComboboxEmpty,
ComboboxGroup,
ComboboxInput,
ComboboxInputGroup,
ComboboxItem,
ComboboxLabel,
ComboboxList,
ComboboxSeparator,
ComboboxTrigger,
} from "@/components/forme/combobox/combobox";
const ALL = [
{ value: "eur", label: "Euro", group: "Europe" },
{ value: "gbp", label: "Pound sterling", group: "Europe" },
{ value: "chf", label: "Swiss franc", group: "Europe" },
{ value: "usd", label: "US dollar", group: "Americas" },
{ value: "cad", label: "Canadian dollar", group: "Americas" },
{ value: "brl", label: "Brazilian real", group: "Americas" },
{ value: "jpy", label: "Japanese yen", group: "Asia" },
{ value: "inr", label: "Indian rupee", group: "Asia" },
] as const;
type Currency = (typeof ALL)[number];
const GROUPS = [...new Set(ALL.map((entry) => entry.group))].map((group) => ({
value: group,
items: ALL.filter((entry) => entry.group === group),
}));
export function ComboboxDemo() {
const [currency, setCurrency] = useState<Currency | null>(null);
return (
<div className="flex max-w-sm flex-col gap-8">
<div className="grid gap-1.5">
<label htmlFor="currency" className="text-body-medium">
Billing currency
</label>
<Combobox
items={GROUPS}
value={currency}
onValueChange={(next) => setCurrency(next)}
// Base UI compares option values by reference, so the label is what a
// screen reader hears and what the field echoes back once chosen.
itemToStringLabel={(item: Currency) => item.label}
itemToStringValue={(item: Currency) => item.value}
>
<ComboboxInputGroup>
<ComboboxInput id="currency" placeholder="Search currencies…" />
<ComboboxTrigger aria-label="Show currencies" />
</ComboboxInputGroup>
<ComboboxContent>
<ComboboxEmpty>No currency matches that.</ComboboxEmpty>
<ComboboxList>
{(group: (typeof GROUPS)[number], index: number) => (
<ComboboxGroup key={group.value} items={group.items}>
{index > 0 ? <ComboboxSeparator /> : null}
<ComboboxLabel>{group.value}</ComboboxLabel>
<ComboboxCollection>
{(item: Currency) => (
<ComboboxItem key={item.value} value={item}>
{item.label}
</ComboboxItem>
)}
</ComboboxCollection>
</ComboboxGroup>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<p className="text-caption-1-regular text-muted-foreground">
{currency ? `Invoices are issued in ${currency.label}.` : "Type to filter the list."}
</p>
</div>
<div className="grid gap-1.5">
<label htmlFor="free" className="text-body-medium">
Any currency
</label>
<Combobox items={ALL} itemToStringLabel={(item: Currency) => item.label}>
<ComboboxInputGroup>
<ComboboxInput id="free" placeholder="Search currencies…" />
<ComboboxTrigger aria-label="Show currencies" />
</ComboboxInputGroup>
<ComboboxContent>
<ComboboxEmpty>No currency matches that.</ComboboxEmpty>
<ComboboxList>
{(item: Currency) => (
<ComboboxItem key={item.value} value={item}>
{item.label}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxInputGroup,
ComboboxItem,
ComboboxList,
} from "@/components/forme/combobox/combobox";
<Combobox items={currencies}>
<ComboboxInputGroup>
<ComboboxInput placeholder="Search currencies…" />
</ComboboxInputGroup>
<ComboboxContent>
<ComboboxList>
{(item) => <ComboboxItem key={item.value} value={item}>{item.label}</ComboboxItem>}
</ComboboxList>
</ComboboxContent>
</Combobox>When to use
Reach for it
- Picking one value from a list long enough that typing is faster than scrolling.
- Grouped options: wrap each set in
ComboboxGroupwith aComboboxLabel, and the search still spans the whole list. - Options that are objects rather than strings: pass
itemToStringLabeland the field echoes the label while the form submits the value.
Use something else
- A short fixed list; a
Selectshows every option at once and costs one click. - Choosing several values; that is a
MultiSelect, which is the same primitive with chips. - Free text with no list behind it; that is an
Input.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
ComboboxValue
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — |
Also takes every prop of Base UI Combobox.Value.
ComboboxItem
One option.
| Prop | Type | Default | Description |
|---|---|---|---|
destructive | boolean | — | Renders destructive: for an option the reader should think twice about. |
Also takes every prop of Base UI Combobox.Item.
The other parts
ComboboxTakesComponentProps<typeof ComboboxPrimitive.Root<Value, Multiple, Item>>ComboboxInputGroupTakes Base UICombobox.InputGroupComboboxInputTakes Base UICombobox.InputComboboxTriggerTakes Base UICombobox.TriggerComboboxClearTakes Base UICombobox.ClearComboboxContentTakes Base UICombobox.PopupandPick<ComponentProps<typeof ComboboxPrimitive.Positioner>, "side" | "sideOffset" | "align">ComboboxListTakes Base UICombobox.ListComboboxEmptyTakes Base UICombobox.EmptyComboboxGroupTakes Base UICombobox.GroupComboboxCollectionTakes Base UICombobox.CollectionComboboxLabelTakes Base UICombobox.GroupLabelComboboxSeparatorTakes Base UICombobox.Separator
Accessibility
- Base UI supplies the combobox and listbox roles,
aria-activedescendanton the highlighted option, and arrow keys, Home and End. - Typing filters without closing the popup, so the results are announced as the list shrinks.
- The empty state stays mounted so a screen reader hears that there are no matches; it is
:emptythat hides it, not a conditional render.
Motion
- The popup grows from its trigger and exits faster than it enters, both on the shared tokens.
- The trigger's chevron rotates while the popup is open; nothing else moves, so the list does not shift under the pointer.
Responsive behaviour
- The popup matches the field's width and is clamped to the room above or below it, so a long list scrolls instead of leaving the viewport.
Related


Select
A choice from a list too long for radio buttons. Grouped with labels, an inline check on the selected option, typeahead and arrow-key navigation from the Base UI select primitive, and a label in the trigger that rolls in the direction of the list — down for a later option, up for an earlier one.
forms

Checkbox
A single choice with a visible label wired to it for a screen reader. An indeterminate state for a select-all with only some rows picked, a description read as a description rather than folded into the name, a destructive variant, and a mark that draws itself in.
forms

Poll
A question to vote on that turns into its results in place: bars grow to each share, the percentages roll and always total 100, and your choice is marked. Single or multiple choice, on real radios and checkboxes.
forms