Select

Alpha

An accessible dropdown select with keyboard navigation, type-ahead, and compound component API.

Import

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

Usage

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

const options = [
  { value: "sm", label: "Small" },
  { value: "md", label: "Medium" },
  { value: "lg", label: "Large" },
];

function Example() {
  return (
    <Select
      options={options}
      placeholder="Choose a size"
    />
  );
}

Features

  • Full keyboard navigation
  • Type-ahead character search
  • Placeholder support
  • Compound component API
  • ARIA listbox pattern

Props

Select component props
PropTypeDefaultDescription
options*{ value: string; label: string }[]-List of options
valuestring-Controlled selected value
onValueChange(value: string) => void-Called when selection changes
placeholderstring'Select...'Placeholder text
disabledbooleanfalseDisables the select

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Select
KeyAction
Enter / SpaceOpens/closes the select
ArrowDownOpens select / moves to next option
ArrowUpMoves to previous option
HomeMoves to first option
EndMoves to last option
EscapeCloses the select
Type charactersType-ahead to jump to option