# Combobox

Search a list and choose one value, or several with type="multiple", with clear loading and error messages.

- **Use it for**: One choice, or several with type="multiple", from a long list people search, including results loaded from your server.
- **Not for**: Short lists where scanning is faster than typing. Try [Select](https://unseenui.com/components/select/), [ToggleGroup](https://unseenui.com/components/toggle-group/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Combobox } from '@stackunseen/ui/application';
import '@stackunseen/ui/styles.css';
import '@stackunseen/ui/application.css';

<Combobox label="Owner" options={owners} value={owner} onValueChange={setOwner}
  query={query} onQueryChange={setQuery} />
```

## Props

- `label` (`string`): Visible field label and option-list name.
- `options` (`readonly ComboboxOption[]`): Stable value, label, optional description and disabled reason. At most 200 matches are shown with a refinement hint.
- `type` (`'single' | 'multiple' (optional)`): Multiple keeps several selected IDs, shown as removable chips below the field, independent of the current results.
- `value` (`string | null, or readonly string[] with type="multiple"`): Selected ID or IDs. A value outside the loaded options remains explicit.
- `onValueChange` (`(value) => void`): Accept a requested selection, toggle or clear in your application.
- `query` (`string`): Current search text.
- `onQueryChange` (`(query: string) => void`): Update the search text and, if needed, load new results from your server.
- `status` (`'ready' | 'loading' | 'error' (optional)`): Actual option availability. Supply error for a useful failure message.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `description` | `string` |  |
| `disabled` | `boolean` |  |
| `error` | `string` |  |
| `filterOption` | `false \| ((option: T, query: string) => boolean)` | false delegates filtering to the host, for example for remote searches. |
| `invalid` | `boolean` |  |
| `label` (required) | `string` | Visible label for the search input and option list. |
| `onQueryChange` (required) | `(query: string) => void` |  |
| `onValueChange` (required) | `(value: string \| null) => void \| (value: readonly string[]) => void` |  |
| `options` (required) | `readonly T[]` |  |
| `placeholder` | `string` |  |
| `query` (required) | `string` |  |
| `required` | `boolean` | An accessibility hint; validate the controlled selection in the host. |
| `status` | `"ready" \| "loading" \| "error"` |  |
| `type` | `"single" \| undefined \| "multiple"` |  |
| `value` (required) | `string \| null \| readonly string[]` |  |

## Keyboard

Arrow keys move through options. Enter selects, Escape closes, and Tab leaves the field. Focus stays in the input.

## Works with

[Field](https://unseenui.com/components/field/), [Input](https://unseenui.com/components/input/), [Textarea](https://unseenui.com/components/textarea/), [Checkbox](https://unseenui.com/components/checkbox/), [Switch](https://unseenui.com/components/switch/), [RadioGroup](https://unseenui.com/components/radio-group/), [TonePad](https://unseenui.com/components/tone-pad/), [Slider](https://unseenui.com/components/slider/), [InputGroup](https://unseenui.com/components/input-group/), [Calendar](https://unseenui.com/components/calendar/), [DateRangePicker](https://unseenui.com/components/date-range-picker/), [Select](https://unseenui.com/components/select/)

Page: https://unseenui.com/components/combobox/
