Skip to main content

ComboBox

A text input with a filterable dropdown listbox (type-ahead select).

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When 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 Select is 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​

PropTypeRequiredDescription
labelReact.ReactNode—Visible label. Without one, set aria-label or aria-labelledby.
descriptionstring—Id of an element that names the field.
items(string | T | ComboBoxSection&lt;T&gt;)[]YesOptions 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.
valuestring | null—Controlled selected key (single mode); null for none.
defaultValuestring—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) =&gt; void—Fired with the selected key (null when cleared) and its item (single mode).
inputValuestring—Controlled input text.
defaultInputValuestring—
onInputChange(text: string) =&gt; void—Fired as the text changes — e.g. to run a server search with filter={false}.
defaultSelectedKeysstring[]—Pre-selected values (multiple mode).
selectedKeysstring[]—Controlled selected values (multiple mode).
onSelectionChange(values: string[]) =&gt; void—Fired in multiple mode with the full selected value array.
onSelect(value: string, item: T | null) =&gt; void—Fired when an item is chosen (and with free text when allowsCustomValue).
filter((item: T, inputText: string) =&gt; boolean) | false—Custom matching, or false to show items unfiltered (server-side search). Default: label, textValue and keywords.
emptyStateReact.ReactNode—Shown in the list when nothing matches. Default "No matches".
footerReact.ReactNode—Pinned to the bottom of the list, e.g. "Showing 60 of 616 — type to search".
isLoadingboolean—Shows a spinner in the field (and "Loading…" in an empty list).
namestring—Form field name: the selected key (or keys, in multiple mode) submit natively.
formstring—Id of the form to submit with, when the ComboBox sits outside it.
isRequiredboolean—Blocks submit until something is chosen (native required).
isInvalidboolean—
errorMessagestring—
leadingIconReact.ReactNode—Icon inside the start of the field, e.g. a search glyph.
autoFocusboolean—Focus the field on mount (without opening the list).
renderSelected(item: T) =&gt; React.ReactNode—Renders a detail for the chosen item under the field (single mode). Client components only.
clearOnSelectboolean—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.
placeholderstring—
allowsCustomValueboolean—Allow free text that isn't in the list (it submits as the value).
isDisabledboolean—
idstring—
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.
classNamestring—