āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/cosscom/coss/components/combobox ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
title: Combobox description: An input combined with a list of predefined items to select.
<ComponentPreview name="combobox-demo" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
npx shadcn@latest add @coss/combobox
</TabsPanel>
<TabsPanel value="manual">
<Steps>
<Step>Install the following dependencies:</Step>
npm install @base-ui-components/react
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="combobox" title="components/ui/combobox.tsx" /><Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsPanel> </CodeTabs>import {
Combobox,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxPopup,
} from "@/components/ui/combobox"
const items = [
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
{ value: "orange", label: "Orange" },
{ value: "grape", label: "Grape" },
]
<Combobox items={items}>
<ComboboxInput placeholder="Select an item..." />
<ComboboxPopup>
<ComboboxEmpty>No results found.</ComboboxEmpty>
<ComboboxList>
{(item) => <ComboboxItem key={item.value} value={item}>{item.label}</ComboboxItem>}
</ComboboxList>
</ComboboxPopup>
</Combobox>
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxPopup,
ComboboxValue,
} from "@/components/ui/combobox"
const items = [
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
{ value: "orange", label: "Orange" },
{ value: "grape", label: "Grape" },
]
<Combobox items={items} multiple>
<ComboboxChips>
<ComboboxValue>
{(value: { value: string; label: string }[]) => (
<>
{value?.map((item) => (
<ComboboxChip key={item.value} aria-label={item.value}>
{item.label}
</ComboboxChip>
))}
<ComboboxInput
placeholder={value.length > 0 ? undefined : "Select a Select an item..."}
aria-label="Select an item"
/>
</>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxPopup>
<ComboboxEmpty>No results found.</ComboboxEmpty>
<ComboboxList>
{(item) => <ComboboxItem value={item}>{item.label}</ComboboxItem>}
</ComboboxList>
</ComboboxPopup>
</Combobox>
The ComboboxInput component extends the original Base UI component with a few extra props:
| Prop | Type | Default | Description |
| ------------- | --------------------------- | ----------- | ------------------------------------------------------------------------------------------------ |
| size | "sm" \| "default" \| "lg" | "default" | The size variant of the input field. |
| showTrigger | boolean | true | Whether to display a trigger button (chevron icon) on the right side of the input. |
| showClear | boolean | false | Whether to display a clear button (X icon) on the right side of the input when there is a value. |
<ComponentPreview name="combobox-disabled" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-sm" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-lg" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-with-label" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
Automatically highlight the first matching option.
<ComponentPreview name="combobox-autohighlight" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-with-clear" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-grouped" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-multiple" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-with-inner-input" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-form" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
<ComponentPreview name="combobox-multiple-form" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-64" />
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā