Combobox

Alpha

An accessible autocomplete/combobox with filtering, keyboard navigation, and compound component API.

Import

import { Combobox } from "@compa11y/react";

Usage

Example.tsx
import { Combobox } from "@compa11y/react";

const fruits = [
  { value: "apple", label: "Apple" },
  { value: "banana", label: "Banana" },
  { value: "cherry", label: "Cherry" },
  { value: "grape", label: "Grape" },
];

function Example() {
  return (
    <Combobox
      options={fruits}
      placeholder="Search fruits..."
      clearable
    />
  );
}

Features

  • Type-ahead filtering
  • Keyboard navigation with arrow keys
  • Clearable input
  • Custom empty state message
  • ARIA combobox pattern compliant
  • Compound component API

Props

Combobox component props
PropTypeDefaultDescription
options*{ value: string; label: string }[]-List of options
valuestring-Controlled selected value
onValueChange(value: string) => void-Called when value changes
placeholderstring-Input placeholder text
clearablebooleanfalseShows clear button
emptyMessagestring'No results'Message when no options match

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Combobox
KeyAction
ArrowDownOpens listbox / moves to next option
ArrowUpMoves to previous option
EnterSelects the focused option
EscapeCloses the listbox
HomeMoves to the first option
EndMoves to the last option