Skip to content
Pixelbits
Docs / Combobox
Forms

Combobox

A text field with a filtered list of choices, for long lists where people type to search (people, countries, components). Follows the ARIA combobox pattern: focus stays in the input, arrows move through the list, Enter picks, Escape closes (and clears the text when already closed). Matching text is highlighted.

Type to filter

Installation

npm: import
import { Combobox } from "pixelbits/combobox";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/combobox.json

API

<Combobox>

A text field with a filtered list of choices, for long lists where people type to search (people, countries, components). Follows the ARIA combobox pattern: focus stays in the input, arrows move through the list, Enter picks, Escape closes (and clears the text when already closed). Matching text is highlighted.

Example
<Field label="Assignee">
  <Combobox options={people} start={<SearchIcon />} placeholder="Search people" onValueChange={assign} />
</Field>
PropTypeDefaultDescription
options*Option[]—

All choices; the list shows the ones that match what is typed.

valuestring—

The selected value (controlled). Use "" for none.

defaultValuestring—

The value selected at first (uncontrolled).

onValueChange(value: string) => void—

Called with the value the user picked.

onQueryChange(query: string) => void—

Called with the text as the user types, for example to load options from a server. The list is still filtered with filter unless it is false.

filter((option: Option, query: string) => boolean) | falsecontainsFilter (label contains the text, ignoring case)

Which options match the typed text. false shows every option (when the server already filters them).

emptyTextReactNode"No results"

Shown in the list when nothing matches.

startReactNode—

Content before the text, usually a search icon.

namestring—

Form field name: a hidden input carries the selected value.

size"sm" | "md" | "lg""md"

Height: "sm" 32 px, "md" 40 px, "lg" 48 px.

Also accepts every prop of Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "size">.