Listbox Pattern
You'll learn what a listbox widget is, how it differs from native selects, and the core ARIA and keyboard behaviors needed to make it accessible.
A listbox is an interactive widget that presents a list of options to the user, similar to a native <select> element but with more visual flexibility and control. Unlike a combobox (which combines text input with a list), a listbox is purely a selectable list that can support single or multiple selections.
When to Use a Listbox
Use a listbox when you need a visually custom selection interface — for example, a list of product variants, color swatches, or filtering options. The native <select> might not offer enough styling control or the ability to show multiple visible options at once.
Core Accessibility Requirements
ARIA roles:
- Use
role="listbox"on the container - Use
role="option"on each selectable item
Keyboard navigation:
- Arrow keys (Up/Down) move focus between options
- Home/End jump to first/last option
- Space or Enter selects the focused option (in single-select mode, focus often equals selection)
- For multi-select: Ctrl+Arrow moves focus without changing selection, Space toggles selection
ARIA states:
aria-selected="true"on selected optionsaria-multiselectable="true"on the listbox if multi-select is enabledaria-activedescendantcan manage focus if you use a roving focus pattern
Structure Example (Conceptual)
<div role="listbox" aria-labelledby="list-label">
<div role="option" aria-selected="true">Option 1</div>
<div role="option" aria-selected="false">Option 2</div>
<div role="option" aria-selected="false">Option 3</div>
</div>
Key Takeaway: The listbox pattern creates an accessible, custom selection widget using ARIA roles, keyboard arrow navigation, and aria-selected states to communicate choices to assistive technologies.