All components

Combobox

Filter a list of choices as you type.

Examples

Filter a list of choices as you type

React code
import {
  Combobox,
  Label,
  ComboboxInput,
  ComboboxOptions,
  ComboboxOption,
} from "@accelerate/react/components";

export function Example() {
  return (
    <>
      <Combobox>
        <Label htmlFor="team-search">Team</Label>
        <ComboboxInput id="team-search" />
        <ComboboxOptions id="team-results" aria-label="Teams">
          <ComboboxOption value="ops">Operations</ComboboxOption>
          <ComboboxOption value="support">Support</ComboboxOption>
          <ComboboxOption value="finance">Finance</ComboboxOption>
        </ComboboxOptions>
      </Combobox>
    </>
  );
}
Angular code
import { Component } from "@angular/core";
import {
  AccCombobox,
  AccLabel,
  AccComboboxInput,
  AccComboboxOptions,
  AccComboboxOption,
} from "@accelerate/angular/components";

@Component({
  selector: "app-example",
  imports: [
    AccCombobox,
    AccLabel,
    AccComboboxInput,
    AccComboboxOptions,
    AccComboboxOption,
  ],
  template: `
    <div accCombobox>
      <label accLabel for="team-search">Team</label>
      <input accComboboxInput id="team-search">
      <div accComboboxOptions id="team-results" aria-label="Teams">
        <button accComboboxOption value="ops">Operations</button>
        <button accComboboxOption value="support">Support</button>
        <button accComboboxOption value="finance">Finance</button>
      </div>
    </div>
  `,
})
export class Example {}

Installation

Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.

React
@accelerate/ui@0.4.0 and @accelerate/react@0.4.0
Angular
@accelerate/ui@0.4.0 and @accelerate/angular@0.2.0

Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.

Usage

Compose a labeled ComboboxInput, a uniquely identified ComboboxOptions, and valued ComboboxOption buttons. Filters by the option text or data-label. Reports the selected option value.

Import the React component Combobox from @accelerate/react/components. For Angular, add AccCombobox to the standalone component’s imports and use <div accCombobox>.

Examples use these React parts: Combobox, Label, ComboboxInput, ComboboxOptions, ComboboxOption. The Angular examples show the corresponding directives and template hosts.

API reference

ComboboxOptions id
Required by the shared behavior.
data-label
Optional text used to match or display a choice.
valueChange
Emits the selected option value.