Skip to content

Combo Boxes

Combobox is a Picker you can type in. It has the same trigger as SelectTrigger and opens a list with a search box. Typing narrows the list to every option whose text contains what was typed, anywhere in it: “ton” finds “Hampton Inn” and “Boston Heights”. The search reads the label a person sees, never the value (an id).

Use it for a dropdown over a list of records: a Job, a client, a contact, a person, a vendor, an SOV item, an Item. A short fixed list such as a status or a type stays a Select.

Live demo

The component below is the real one the app ships. Type “ton” in the list.

The Command list it is built on, shown on its own, and the older Popover composition:

Usage

Source: Combobox.tsx

import { Combobox, Label } from "@beacon/design-system";
<Label htmlFor="job">Job</Label>
<Combobox
id="job"
options={jobs.map((j) => ({ value: j.id, label: j.name }))}
value={jobId}
onValueChange={setJobId}
placeholder="Pick a Job"
noneLabel="No Job"
/>
PropRole
options{ value, label }[]. The search matches label.
value / onValueChangeAs on Select. "" is no selection.
placeholder, searchPlaceholder, emptyMessageTrigger text, search box text, text when nothing matches.
noneLabelAdds a first entry with this label that clears the value.
idOn the trigger, so Label htmlFor reaches it.
disabled, classNameAs on SelectTrigger.

The list opens above a modal or Fly-In. Arrows and Enter move and choose; Esc closes only the list; a second click on the trigger closes it. At 390px the trigger is at least 44px tall.

Source: command.tsx, popover.tsx

The Command searchable list on its own:

import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@beacon/design-system";
<Command className="rounded-lg border shadow-md w-[350px]">
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions">
<CommandItem>Calendar</CommandItem>
<CommandItem>Search Emoji</CommandItem>
<CommandItem>Calculator</CommandItem>
</CommandGroup>
</CommandList>
</Command>

The composition Combobox is built from, for a picker that needs more than one value or custom rows: Command inside a Popover, with a trigger that reflects the selection. For several values use MultiSelect.

import {
Button,
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
Popover,
PopoverContent,
PopoverTrigger,
} from "@beacon/design-system";
const [open, setOpen] = React.useState(false);
const [value, setValue] = React.useState("");
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button variant="outline" role="combobox" aria-expanded={open}>
{value || "Select framework..."}
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput placeholder="Search framework..." />
<CommandList>
<CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup>
<CommandItem onSelect={(v) => { setValue(v); setOpen(false); }}>
Next.js
</CommandItem>
<CommandItem onSelect={(v) => { setValue(v); setOpen(false); }}>
Remix
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>

Parts

Combobox is assembled from these exports.

PartRole
CommandRoot searchable list. Filters its items as the input changes (cmdk).
CommandInputThe search field at the top (renders a search icon).
CommandListScroll container for the results.
CommandEmptyShown when no item matches the query.
CommandGroupGroups items under an optional heading.
CommandItemA selectable row; use onSelect to capture the choice.
CommandSeparatorDivider between groups.
CommandShortcutRight-aligned hint text (e.g. a keyboard shortcut) inside an item.
CommandDialogVariant that renders the command list inside a centered dialog (command-palette style).
Popover / PopoverTrigger / PopoverContentWrap Command to turn it into a field that opens on click. Use PopoverContent className="w-[...] p-0".

When to use

  • A dropdown over records (a Job, a client, a vendor, an Item) where typing to filter is faster than scrolling.
  • An app-wide command palette (use CommandDialog).
  • Autocomplete fields where the user selects from a known set.

Do not reach for this pattern when the list is short and fixed; a plain Picker is simpler and needs no filtering. For free-text entry that is not constrained to a list, use a text Input instead.