StealThis .dev

Autocomplete

Text input with a filtered dropdown suggestion list. Keyboard navigation (↑↓ Enter Escape), highlight match, clear button.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Autocomplete

ARIA combobox with a filtered suggestion list. Matches are highlighted inline. Keyboard-navigable and screen-reader friendly.

Keyboard shortcuts

KeyAction
↓ / ↑Move active item in list
EnterConfirm active item
EscapeClose list and clear
TabClose list

Implementation

Uses role="combobox" on the input with aria-expanded, aria-controls, and aria-activedescendant. Suggestions are a role="listbox" with role="option" items. Matched substrings are wrapped in <mark> for visual highlighting.