Forms
Combobox
Free22.7 KB gzippedAn editable combobox with a list of suggestions (WAI-ARIA APG Combobox, "list autocomplete" with a listbox popup). Type to filter, use the arrow keys to highlight, Enter to choose. Single or multiple selection (chips), groups, descriptions, icons, async loading, and creatable options.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Arrow Down, Arrow Up, Alt+Arrow Down and 4 more · Full report
Import
import { Combobox } from "@vjdesigns/vjdesigns-ui";
Importing only Combobox adds about 22.7 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
Type to filter, use the arrow keys to highlight, and Enter to choose.
Value: ts
import { useState } from "react";
import { Combobox, Field, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
const [value, setValue] = useState<string | null>("ts");
return (
<Stack gap={3} style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Language">
<Combobox
value={value}
onValueChange={setValue}
clearable
options={[
{ value: "ts", label: "TypeScript" },
{ value: "js", label: "JavaScript" },
{ value: "py", label: "Python" },
{ value: "go", label: "Go" },
{ value: "rs", label: "Rust" },
{ value: "kt", label: "Kotlin" },
]}
/>
</Field>
<Text size="sm" tone="muted">
Value: <code>{String(value)}</code>
</Text>
</Stack>
);
}
Grouped
Options can carry a group heading and a description.
import { Combobox, Field } from "@vjdesigns/vjdesigns-ui";
export function Grouped() {
return (
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Time zone">
<Combobox
placeholder="Search time zones"
options={[
{ value: "pt", label: "Pacific Time", description: "Los Angeles, UTC−8", group: "Americas" },
{ value: "et", label: "Eastern Time", description: "New York, UTC−5", group: "Americas" },
{ value: "brt", label: "Brasília Time", description: "São Paulo, UTC−3", group: "Americas" },
{ value: "gmt", label: "Greenwich Mean Time", description: "London, UTC+0", group: "Europe" },
{ value: "cet", label: "Central European Time", description: "Berlin, UTC+1", group: "Europe" },
{ value: "jst", label: "Japan Standard Time", description: "Tokyo, UTC+9", group: "Asia" },
]}
/>
</Field>
</div>
);
}
Long list
10,000 options. Only the options in view are rendered, so opening, scrolling and typing stay instant. Each option still carries its position (aria-posinset, aria-setsize), so screen readers hear "10,000 of 10,000". Filtering ignores accents: "zoe" finds "Zoë". Lists with groups always render in full.
import { Combobox, Field } from "@vjdesigns/vjdesigns-ui";
const placeStarts = ["North", "South", "East", "West", "New", "Port", "Lake", "Fort", "Saint", "Mount"];
const placeEnds = ["Haven", "Ridge", "Field", "Brook", "Dale", "Wood", "Ford", "Bay", "Ámbar", "Zoë"];
const placeEnds = ["Haven", "Ridge", "Field", "Brook", "Dale", "Wood", "Ford", "Bay", "Ámbar", "Zoë"];
const places = Array.from({ length: 10_000 }, (_, i) => ({
value: `place-${i + 1}`,
label: `${placeStarts[i % placeStarts.length]} ${placeEnds[(i * 7) % placeEnds.length]} ${i + 1}`,
}));
export function LongList() {
return (
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Home town">
<Combobox placeholder="Search 10,000 places" options={places} />
</Field>
</div>
);
}
Multiple
With multiple, chosen options show as removable chips.
Pick as many as apply.
import { useState } from "react";
import { Combobox, Field } from "@vjdesigns/vjdesigns-ui";
export function Multiple() {
const [skills, setSkills] = useState<string[]>(["react", "css"]);
return (
<div style={{ width: "100%", maxWidth: "24rem" }}>
<Field label="Skills" hint="Pick as many as apply.">
<Combobox
multiple
value={skills}
onValueChange={setSkills}
options={[
{ value: "react", label: "React" },
{ value: "css", label: "CSS" },
{ value: "a11y", label: "Accessibility" },
{ value: "node", label: "Node.js" },
{ value: "design", label: "Design systems" },
]}
/>
</Field>
</div>
);
}
Accessibility
While the list is open, the number of matching options is announced politely after typing pauses, and a "no matches" row explains an empty list (it can't be chosen by accident). Arrow keys highlight, Enter chooses, Escape closes and then clears.
Start typing a city.
import { Combobox, Field } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Time zone" hint="Start typing a city.">
<Combobox
clearable
emptyMessage="No time zones match. Try a nearby city."
options={[
{ value: "America/New_York", label: "New York (UTC−5)" },
{ value: "America/Mexico_City", label: "Mexico City (UTC−6)" },
{ value: "Europe/London", label: "London (UTC+0)" },
{ value: "Europe/Madrid", label: "Madrid (UTC+1)" },
{ value: "Asia/Tokyo", label: "Tokyo (UTC+9)" },
]}
/>
</Field>
</div>
);
}
Translated
The results announcement, the empty message and the buttons' names come from the locale (Spanish here). Option labels are your own text.
import { Combobox, Field, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import es from "@vjdesigns/vjdesigns-ui/locales/es";
export function Translated() {
return (
<LocaleProvider locale="es" messages={es}>
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Fruta">
<Combobox
clearable
options={[
{ value: "apple", label: "Manzana" },
{ value: "banana", label: "Plátano" },
{ value: "cherry", label: "Cereza" },
{ value: "grape", label: "Uva" },
]}
/>
</Field>
</div>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
Value: ts
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
Usage notes
Inside a Field, the label, hint, error, required, disabled, read-only, and size are wired automatically, as with Input.
<Field label="Team">
<Combobox options={teams} value={team} onValueChange={setTeam} clearable />
</Field>
API reference
Combobox
| Prop | Type | Default |
|---|---|---|
optionsRequiredThe choices. Filtering, grouping, and keyboard order all follow this array. | ComboboxOption[] | — |
renderOptionCustom content for each option, replacing the icon, label, and description. The selected check mark is still drawn. Return | (option: ComboboxOption, state: ComboboxOptionState) => ReactNode | — |
inputValueCurrent input text (controlled). | string | — |
defaultInputValueInitial input text when uncontrolled. Defaults to the selected option's label (single) or "". | string | — |
onInputValueChangeCalled with the new input text on typing, selection, clearing, and reverting. | (inputValue: string) => void | — |
openWhether the list is open (controlled). | boolean | — |
defaultOpenInitial open state when uncontrolled. | boolean | false |
onOpenChangeCalled with the next open state. | (open: boolean) => void | — |
filterHow options are matched against the input text. Defaults to a case- and diacritic-insensitive "contains" match on the label ( | ComboboxFilter | false | — |
loadingShows a loading row with a spinner in the list and marks the listbox | boolean | false |
loadingMessageText of the loading row. | ReactNode | "Loading…" |
emptyMessageStatus row shown when no option matches (not an option, so it can't be chosen). Pass | ReactNode | "No results" |
resultsMessageThe polite, debounced announcement of how many options are shown. | (count: number) => string | (count) => "5 results available" |
allowCustomValueLets the input hold text that matches no option.
| boolean | false |
onCreateMakes the combobox creatable: when the trimmed text matches no option label exactly, a "Create “text”" option appears at the end of the list. Choosing it calls | (inputValue: string) => string | void | — |
createLabelContent of the create option. | (inputValue: string) => ReactNode | (text) => `Create “${text}”` |
clearableShows a clear button (a real button) while there is a selection or text. | boolean | false |
clearLabelAccessible name of the clear button. | string | "Clear selection" |
showSuggestionsLabelAccessible name of the chevron button while the list is closed. | string | "Show suggestions" |
hideSuggestionsLabelAccessible name of the chevron button while the list is open. | string | "Hide suggestions" |
selectedLabelAccessible name of the list of selected chips (multiple). | string | "Selected" |
autoHighlightHighlights the first match while typing, so Enter picks it. Off by default (APG "list autocomplete without automatic selection"). | boolean | — |
loopArrow keys wrap from the last option to the first and back. | boolean | true |
sizeField height, padding, and type size. Inherits from a surrounding | "sm""md""lg" | "md" |
invalidDanger styling and | boolean | false |
requiredRequired. Sets | boolean | — |
requiredMessageValidation message while | string | "Choose an option." |
clearOnEscapeEscape on unchanged text clears the selection too. Off by default, so Escape doesn't silently drop a committed value and can close an enclosing Modal. (Escape always undoes typed text first.) | boolean | false |
disabledDisables the field, chips, and buttons. Inherits from a surrounding | boolean | — |
readOnlyShows the value without allowing changes; the list doesn't open. Inherits from a surrounding | boolean | — |
nameName for form submission. Renders a hidden input with the selected value (one per value when | string | — |
placementPreferred side of the list. Flips when there isn't room. | "top""top-start""top-end""bottom""bottom-start""bottom-end""left""left-start""left-end""right""right-start""right-end" | "bottom-start" |
maxHeightMaximum list height (CSS length, or px as a number). Always capped to the viewport. | CSSProperties["maxHeight"] | 20rem |
fullWidthStretches the field to fill its container. | boolean | true |
containerElement the list portals into. | HTMLElement | null | document.body |
inputClassNameClass name for the | string | — |
refRef to the | Ref<HTMLInputElement> | — |
multipleSelect one option (default) or many. | falsetrue | — |
valueSelected value (controlled). | string | null | string[] | — |
defaultValueInitial value when uncontrolled. | string | null | string[] | null |
onValueChangeCalled with the new value, or | (value: string | null) => void | (value: string[]) => void | — |
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Combobox targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10037 passed · 0 failed · 28 not applicable · 10 to check by hand
Dark mode
Score 10037 passed · 0 failed · 28 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Arrow Down | Opens the list, or moves to the next option. |
| Arrow Up | Opens the list on the last option, or moves to the previous one. |
| Alt+Arrow Down | Opens the list without moving to an option. |
| Alt+Arrow Up | Closes the list. |
| Enter | Chooses the highlighted option (multiple: toggles it). |
| Escape | Closes the list; again: restores the committed text. |
| Backspace | Multiple, empty field: removes the last selected value. |
| Typing | Filters the options. |
Focus stays in the field; the highlighted option is tracked with aria-activedescendant. Long lists without groups render only the options in view, plus the highlighted one, so aria-activedescendant always points at a rendered option.
Roles and states
| Element | Role | States and properties |
|---|---|---|
<input> | combobox | aria-expanded, aria-controls → listbox, aria-activedescendant, aria-autocomplete="list" |
| List | listbox | aria-multiselectable (multiple) |
| Option | option | aria-selected, aria-disabled, aria-setsize and aria-posinset while only part of the list is rendered |
| Result count | status | — |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |