ComboBox
A text input with a filterable dropdown listbox (type-ahead select).
Signature
Density
Viewport
Theme and light/dark are set in the top barWhen to use
- Use it when Pick from a long list with type-ahead, or allow multiple selections.
- Reach for something else when A handful of options where a plain
Selectis simpler.
Accessibility
Always render a visible <label> (the label prop wires htmlFor/id for you). Errors set aria-invalid and are announced via aria-describedby. Required fields expose aria-required.
Install and import
npx shadcn@latest add @prism/combo-box
import { ComboBox } from '@/components/prism/ComboBox';
In a no-build prototype, read it from the bundle instead: const { ComboBox } = window.PrismDesignSystem_39d121;
Props
| Prop | Type | Required | Description |
|---|---|---|---|
label | React.ReactNode | — | Visible label. Without one, set aria-label or aria-labelledby. |
description | string | — | Id of an element that names the field. |
items | (string | T | ComboBoxSection<T>)[] | Yes | Options as strings or item objects, optionally grouped into sections. With filter={false}, these are shown as-is. |
selectionMode | "single" | "multiple" | — | "single" (default) fills the input; "multiple" shows removable chips. |
value | string | null | — | Controlled selected key (single mode); null for none. |
defaultValue | string | — | Initial selected key (single mode). A value that isn't an item key is taken as the starting input text, as before 2.2. |
onChange | (value: string | null, item: T | null) => void | — | Fired with the selected key (null when cleared) and its item (single mode). |
inputValue | string | — | Controlled input text. |
defaultInputValue | string | — | |
onInputChange | (text: string) => void | — | Fired as the text changes — e.g. to run a server search with filter={false}. |
defaultSelectedKeys | string[] | — | Pre-selected values (multiple mode). |
selectedKeys | string[] | — | Controlled selected values (multiple mode). |
onSelectionChange | (values: string[]) => void | — | Fired in multiple mode with the full selected value array. |
onSelect | (value: string, item: T | null) => void | — | Fired when an item is chosen (and with free text when allowsCustomValue). |
filter | ((item: T, inputText: string) => boolean) | false | — | Custom matching, or false to show items unfiltered (server-side search). Default: label, textValue and keywords. |
emptyState | React.ReactNode | — | Shown in the list when nothing matches. Default "No matches". |
footer | React.ReactNode | — | Pinned to the bottom of the list, e.g. "Showing 60 of 616 — type to search". |
isLoading | boolean | — | Shows a spinner in the field (and "Loading…" in an empty list). |
name | string | — | Form field name: the selected key (or keys, in multiple mode) submit natively. |
form | string | — | Id of the form to submit with, when the ComboBox sits outside it. |
isRequired | boolean | — | Blocks submit until something is chosen (native required). |
isInvalid | boolean | — | |
errorMessage | string | — | |
leadingIcon | React.ReactNode | — | Icon inside the start of the field, e.g. a search glyph. |
autoFocus | boolean | — | Focus the field on mount (without opening the list). |
renderSelected | (item: T) => React.ReactNode | — | Renders a detail for the chosen item under the field (single mode). Client components only. |
clearOnSelect | boolean | — | Action picker (single mode): choosing fires onSelect(key, item), then the field empties for the next pick and nothing stays selected (onChange isn't called). Focus stays in the field. |
placeholder | string | — | |
allowsCustomValue | boolean | — | Allow free text that isn't in the list (it submits as the value). |
isDisabled | boolean | — | |
id | string | — | |
width | "xs" | "sm" | "md" | "lg" | "full" | — | Maximum width: "xs" (8rem) | "sm" (12rem) | "md" (20rem) | "lg" (36rem) | "full" (default). A cap, not a fixed width — it still shrinks on a phone or in a narrow FormRow column; the label and messages follow it. Sizes are the --field-width-* tokens. |
className | string | — |