Combobox — dir/ui
Searches a long or remote list and picks one value, or several shown as chips.
# Combobox
Searches a long or remote list and picks one value, or several shown as chips.
Live preview of every variant and state: https://ui.usedir.com/components/combobox
## Install
```sh
npx shadcn@4.21.0 add lr-run/dir-ui/combobox#v0.4.0
```
[Registry item with source and dependencies](https://github.com/lr-run/dir-ui/blob/v0.4.0/registry.json)
Requires React 19, Tailwind CSS 4 and shadcn initialized with Base UI: npx shadcn@4.21.0 init --base base --preset base-nova (in Vite, set up the @/* path alias in tsconfig.json and vite.config.ts first). Registry target placeholders resolve through components.json: @ui, @components, @hooks and @lib. Imports below use the conventional @/ prefix for illustration; the CLI rewrites them to your configured aliases. Shared components are installed once through registryDependencies. The installer merges shared theme rules into the stylesheet configured in components.json. Existing files are never forcibly overwritten; review CLI conflicts before accepting changes. No Dir runtime is required.
## SingleCombobox, MultiCombobox
```tsx
import { SingleCombobox, MultiCombobox } from '@/components/ui/combobox.tsx'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| value | string \| null | Required | |
| onValueChange | (value: string \| null) => void | Required | |
| items | Choice[] | Required | |
| label | string | Required | Accessible input name. |
| selectedItems | Choice[] | [] | Supply selected labels that are absent from current search results. |
| disabled / invalid | boolean | false | |
| loadOptions | LoadChoices | — | Optional remote search. Honor the AbortSignal; keep this callback stable. |
| debounceMs | number | 150 | |
| maxVisible | number | 100 | Limit local options only. Remote results keep every explicitly loaded page visible. |
| autoFocus | boolean | false | Focus the input and open its options on mount. |
| modal | boolean | false | Use false for editors nested in a grid. |
| renderOption / renderValue | (item: Choice) => ReactNode | — | renderValue customizes multi-value chips. |
| onCreate | (query: string) => void | — | Optional create action; caller owns the workflow. |
| placeholder | string | Search to select… | |
| clearable | boolean | true | Single selection only. |
| id / ref / onBlur / aria-describedby | Input bindings | — | Connect controlled forms through React Hook Form Controller. |
```ts
type Choice = { value: string; label: string; description?: string; color?: string; avatar?: string; disabled?: boolean; keywords?: string[] }
type LoadChoices = (query: string, context: { signal: AbortSignal; cursor?: string }) => Promise<{ items: Choice[]; cursor?: string }>
```
## MultiCombobox
```tsx
import { MultiCombobox } from '@/components/ui/combobox.tsx'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| value | string[] | Required | |
| onValueChange | (value: string[]) => void | Required | |
| items | Choice[] | Required | |
| label | string | Required | Accessible input name. |
| selectedItems | Choice[] | [] | Supply selected labels that are absent from current search results. |
| disabled / invalid | boolean | false | |
| loadOptions | LoadChoices | — | Optional remote search. Honor the AbortSignal; keep this callback stable. |
| debounceMs | number | 150 | |
| maxVisible | number | 100 | Limit local options only. Remote results keep every explicitly loaded page visible. |
| autoFocus | boolean | false | Focus the input and open its options on mount. |
| modal | boolean | false | Use false for editors nested in a grid. |
| renderOption / renderValue | (item: Choice) => ReactNode | — | renderValue customizes multi-value chips. |
| onCreate | (query: string) => void | — | Optional create action; caller owns the workflow. |
| placeholder | string | Search to select… | |
| clearable | boolean | true | Single selection only. |
| id / ref / onBlur / aria-describedby | Input bindings | — | Connect controlled forms through React Hook Form Controller. |
```ts
type Choice = { value: string; label: string; description?: string; color?: string; avatar?: string; disabled?: boolean; keywords?: string[] }
type LoadChoices = (query: string, context: { signal: AbortSignal; cursor?: string }) => Promise<{ items: Choice[]; cursor?: string }>
```