GitHub

Combobox

A component that displays a combobox.

Installation#

Usage#

import {
Combobox,
ComboboxContent,
ComboboxControl,
ComboboxHiddenSelect,
ComboboxInput,
ComboboxItem,
ComboboxItemIndicator,
ComboboxItemLabel,
ComboboxSection,
ComboboxTrigger,
} from "~/components/ui/combobox";
<Combobox<Food, Category>
options={ALL_OPTIONS}
optionValue="value"
optionTextValue="label"
optionLabel="label"
optionDisabled="disabled"
optionGroupChildren="options"
placeholder="Search a food…"
itemComponent={(props) => (
<ComboboxItem item={props.item}>
<ComboboxItemLabel>{props.item.rawValue.label}</ComboboxItemLabel>
<ComboboxItemIndicator />
</ComboboxItem>
)}
sectionComponent={(props) => (
<ComboboxSection>{props.section.rawValue.label}</ComboboxSection>
)}
>
<ComboboxControl aria-label="Food" class="bg-background">
<ComboboxInput />
<ComboboxTrigger />
</ComboboxControl>
<ComboboxContent />
</Combobox>