Components
Combobox
A searchable input with a popup list of options.
Combobox is built on the Base UI Combobox primitive. Pass an items array to the root and render items with a function child so the list can filter and show an empty state.
"use client";
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox";
const fruits = [
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
];
export default function Example() {
return (
<Combobox items={fruits}>
<ComboboxInput placeholder="Search a fruit..." className="w-56" />
<ComboboxContent>
<ComboboxEmpty>No results.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item.value} value={item}>
{item.label}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
);
}Installation
pnpm dlx shadcn@latest add https://faber-ui.vercel.app/r/combobox.jsonExamples
Default
With groups
API
Each part forwards every prop of what it is built on, including className and render where Base UI supports it. The props column lists only what Faber UI adds on top.
| Part | Built on | Props |
|---|---|---|
Combobox | Combobox.RootBase UI | — |
ComboboxValuedata-slot="combobox-value" | Combobox.ValueBase UI | — |
ComboboxTriggerdata-slot="combobox-trigger" | Combobox.TriggerBase UI | — |
ComboboxInput | Combobox.InputBase UI |
|
ComboboxContentdata-slot="combobox-content" | Combobox.PopupBase UI |
|
ComboboxListdata-slot="combobox-list" | Combobox.ListBase UI | — |
ComboboxItemdata-slot="combobox-item" | Combobox.ItemBase UI | — |
ComboboxGroupdata-slot="combobox-group" | Combobox.GroupBase UI | — |
ComboboxLabeldata-slot="combobox-label" | Combobox.GroupLabelBase UI | — |
ComboboxCollectiondata-slot="combobox-collection" | Combobox.CollectionBase UI | — |
ComboboxEmptydata-slot="combobox-empty" | Combobox.EmptyBase UI | — |
ComboboxSeparatordata-slot="combobox-separator" | Combobox.SeparatorBase UI | — |
ComboboxChipsdata-slot="combobox-chips" | Combobox.ChipsBase UI | — |
ComboboxChipdata-slot="combobox-chip" | Combobox.ChipBase UI |
|
ComboboxChipsInputdata-slot="combobox-chip-input" | Combobox.InputBase UI | — |
useComboboxAnchor | Hook | — |
| Component | Description |
|---|---|
Combobox | Root. Accepts value, defaultValue, onValueChange. |
ComboboxInput | The search input. Also acts as the popup trigger. |
ComboboxContent | The popup container. |
ComboboxList | The scrollable list of items. |
ComboboxItem | A single option. Accepts value. |
ComboboxGroup | Groups related items. |
ComboboxLabel | Non-interactive label for a group. |
ComboboxEmpty | Shown when there are no results. |
ComboboxSeparator | Horizontal divider. |
ComboboxChips | Container for selected value chips (multi-select). |
ComboboxChip | A single chip. |
ComboboxChipsInput | The input rendered inside the chips container. |
ComboboxTrigger | The trigger button. |
ComboboxValue | Displays the selected value(s). |
Changelog
- v0.3.0Popover, DropdownMenu, ContextMenu, Menubar, Select, Combobox, HoverCard, Tooltip, Dialog and AlertDialog enter and exit with interruptible transitions on the kit easing tokens, and tw-animate-css is no longer a depen…minor
- v0.3.0Input, Textarea, NativeSelect, CommandInput and ComboboxChipsInput use 16px text on small screens so iOS Safari no longer zooms the page on focus.patch
- v0.3.0KbdGroup is typed as a kbd element, Combobox imports its Base UI subpath, the motion lib mirrors the exit easing and travel tokens, and the chart item declares its react-is peer.patch
- v0.1.0Restore open and close animations on every menu-family popup.patch
Last updated on