Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

Combobox

Free22.7 KB gzipped

An 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

tsx
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

tsx
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.

tsx
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.

tsx
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.

ReactCSS

Pick as many as apply.

tsx
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.

tsx
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.

tsx
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

tsx
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.

tsx
<Field label="Team">
  <Combobox options={teams} value={team} onValueChange={setTeam} clearable />
</Field>

API reference

Combobox

Combobox props
PropTypeDefault
optionsRequired

The choices. Filtering, grouping, and keyboard order all follow this array.

ComboboxOption[]—
renderOption

Custom content for each option, replacing the icon, label, and description. The selected check mark is still drawn. Return undefined to use the default content for an option. The option's accessible name is then its whole text content.

(option: ComboboxOption, state: ComboboxOptionState) => ReactNode—
inputValue

Current input text (controlled).

string—
defaultInputValue

Initial input text when uncontrolled. Defaults to the selected option's label (single) or "".

string—
onInputValueChange

Called with the new input text on typing, selection, clearing, and reverting.

(inputValue: string) => void—
open

Whether the list is open (controlled).

boolean—
defaultOpen

Initial open state when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state.

(open: boolean) => void—
filter

How options are matched against the input text. Defaults to a case- and diacritic-insensitive "contains" match on the label (defaultComboboxFilter). Pass false for async or server-side filtering: every option in options is shown as is.

ComboboxFilter | false—
loading

Shows a loading row with a spinner in the list and marks the listbox aria-busy. The loading message is announced politely.

booleanfalse
loadingMessage

Text of the loading row.

ReactNode"Loading…"
emptyMessage

Status row shown when no option matches (not an option, so it can't be chosen). Pass null to close the list instead.

ReactNode"No results"
resultsMessage

The polite, debounced announcement of how many options are shown.

(count: number) => string(count) => "5 results available"
allowCustomValue

Lets the input hold text that matches no option.

  • Single: the text is kept on blur instead of reverting to the selected label (the value becomes null when the text no longer matches it), and the hidden form input submits the text.
  • Multiple: Enter with no highlighted option adds the typed text as a value.
booleanfalse
onCreate

Makes 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 onCreate(text). Add the new option to options; return its value to also select it.

(inputValue: string) => string | void—
createLabel

Content of the create option.

(inputValue: string) => ReactNode(text) => `Create “${text}”`
clearable

Shows a clear button (a real button) while there is a selection or text.

booleanfalse
clearLabel

Accessible name of the clear button.

string"Clear selection"
showSuggestionsLabel

Accessible name of the chevron button while the list is closed.

string"Show suggestions"
hideSuggestionsLabel

Accessible name of the chevron button while the list is open.

string"Hide suggestions"
selectedLabel

Accessible name of the list of selected chips (multiple).

string"Selected"
autoHighlight

Highlights the first match while typing, so Enter picks it. Off by default (APG "list autocomplete without automatic selection").

boolean—
loop

Arrow keys wrap from the last option to the first and back.

booleantrue
size

Field height, padding, and type size. Inherits from a surrounding Field.

"sm""md""lg""md"
invalid

Danger styling and aria-invalid. Inherits from a surrounding Field.

booleanfalse
required

Required. Sets aria-required on the input and blocks native form submission (via setCustomValidity) while nothing is chosen. Inherits from a surrounding Field.

boolean—
requiredMessage

Validation message while required and empty.

string"Choose an option."
clearOnEscape

Escape 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.)

booleanfalse
disabled

Disables the field, chips, and buttons. Inherits from a surrounding Field.

boolean—
readOnly

Shows the value without allowing changes; the list doesn't open. Inherits from a surrounding Field.

boolean—
name

Name for form submission. Renders a hidden input with the selected value (one per value when multiple). The text input itself has no name.

string—
placement

Preferred 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"
maxHeight

Maximum list height (CSS length, or px as a number). Always capped to the viewport.

CSSProperties["maxHeight"]20rem
fullWidth

Stretches the field to fill its container.

booleantrue
container

Element the list portals into.

HTMLElement | nulldocument.body
inputClassName

Class name for the <input>. className goes to the field wrapper.

string—
ref

Ref to the <input role="combobox">.

Ref<HTMLInputElement>—
multiple

Select one option (default) or many.

falsetrue—
value

Selected value (controlled). null means nothing is selected.

string | null | string[]—
defaultValue

Initial value when uncontrolled.

string | null | string[]null
onValueChange

Called with the new value, or null when cleared.

(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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Dark mode

Score 100

37 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

Keyboard
KeyAction
Arrow DownOpens the list, or moves to the next option.
Arrow UpOpens the list on the last option, or moves to the previous one.
Alt+Arrow DownOpens the list without moving to an option.
Alt+Arrow UpCloses the list.
EnterChooses the highlighted option (multiple: toggles it).
EscapeCloses the list; again: restores the committed text.
BackspaceMultiple, empty field: removes the last selected value.
TypingFilters 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

Roles and states
ElementRoleStates and properties
<input>comboboxaria-expanded, aria-controls → listbox, aria-activedescendant, aria-autocomplete="list"
Listlistboxaria-multiselectable (multiple)
Optionoptionaria-selected, aria-disabled, aria-setsize and aria-posinset while only part of the list is rendered
Result countstatus—

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)