Single-Select Listbox
A selectable list of options with Up/Down arrow navigation. Click or press Enter/Space to select an item.
focusgroup="listbox block nomemory"
Try it: Use ↓ and ↑ to
navigate. Press Enter or Space to
select an option.
Apple
Banana
Cherry
Date
Elderberry
Fig
Grape
Honeydew
- Up/Down arrows navigate between options
- Home and End are not built into
focusgroup. Add JavaScript handlers if your listbox pattern requires them - The listbox is a single tab stop. Tab enters, arrows navigate, and Tab exits.
- Selection state (
aria-selected) is managed by JavaScript.focusgrouphandles navigation only. - This demo uses "browse-then-confirm" selection (Enter or Space
to select after arrowing). The ARIA APG recommends
selection-follows-focus for single-select listboxes; add a
focusevent handler callingselect(item)on each option for that behavior. <div>children are not natively focusable (thelistboxtoken infersrole="option"on each). Give every optiontabindex="0"so the browser can focus it.focusgroupcollapses those tab stops into one. No manualtabindex="-1"management needed.listboxhas no default axis modifier. The explicitblockhere applies Up/Down arrow navigation. Without it, no axis would be active.
View source
<div focusgroup="listbox block nomemory"
aria-label="Favorite fruit"
aria-multiselectable="false" class="listbox">
<div class="listbox-option selected" tabindex="0"
aria-selected="true" focusgroupstart>Apple</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Banana</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Cherry</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Date</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Elderberry</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Fig</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Grape</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Honeydew</div>
</div>
Listbox with Wrapping
With wrap, navigation continues from the last item
back to the first (and vice versa).
focusgroup="listbox block wrap nomemory"
Try it: Navigate to "Mango" (last item), then
press ↓ and focus wraps to "Avocado".
Avocado
Coconut
Guava
Kiwi
Mango
wrapmakes navigation circular at boundaries- Down from last → first; Up from first → last
- Without
wrap, navigation stops at the boundaries - Unlike
menuandmenubar(which wrap by default),listboxdoes not wrap by default. Thewraptoken here is an explicit opt-in.
View source
<div focusgroup="listbox block wrap nomemory"
aria-label="Tropical fruits"
aria-multiselectable="false" class="listbox">
<div class="listbox-option selected" tabindex="0"
aria-selected="true" focusgroupstart>Avocado</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Coconut</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Guava</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Kiwi</div>
<div class="listbox-option" tabindex="0"
aria-selected="false">Mango</div>
</div>