U.S. flagA digital services project by Flexion

Combo Box

formUSWDS-derivedinteractive

A typeahead/autocomplete select with text input and filterable dropdown list.

Reference: USWDS documentation ↗

Variants

Combo Box With Default

Default Combo Box

Contract

Class mapping

USWDSFlexNotes
usa-combo-box<flex-combo-box> (custom element)Container element
usa-combo-box__input.flex-combo-box__inputText input with combobox role
usa-combo-box__toggle-list.flex-combo-box__toggleToggle dropdown button
usa-combo-box__clear-input.flex-combo-box__clearClear selection button
usa-combo-box__list.flex-combo-box__listDropdown listbox
usa-combo-box__list-option.flex-combo-box__optionIndividual option items
usa-combo-box__list-option--focused[data-focused]Highlighted option via keyboard navigation

Verified properties

font-familyfont-sizeline-heightcolorbackground-colorcursor

Intentional differences

padding-right: ours = 4.5rem (space for toggle + clear buttons), USWDS = 2.5rem (USWDS uses different button layout)

Our layout positions both toggle and clear buttons inside the input area

Behavior promises

  • ✓ Click input opens dropdown showing all options
  • ✓ Typing filters options case-insensitively
  • ✓ Shows "No results found" when filter matches nothing
  • ✓ Click option selects it and closes list
  • ✓ Enter key selects highlighted option
  • ✓ ArrowDown opens list if closed
  • ✓ ArrowDown/Up navigate options
  • ✓ Escape closes list and restores previous value
  • ✓ Tab closes list and keeps selection
  • ✓ Clear button resets input
  • ✓ Outside click closes dropdown
  • ✓ aria-expanded updates on open/close
  • ✓ aria-activedescendant updates on keyboard nav
  • ✓ aria-selected marks the selected option
  • ✓ Accessibility audit passes

Source CSS

Base styles: Form Control Base