listbox

Term side of the Card.
Topic: Basic Control Elements
Unit title: listbox
Categories: Role
Explanation side of the Card

Explanation: The role that represents a widget that allows users to select one or more items from a list of options. It provides a way to present and manage multiple selectable items within a list.

Example

Wronghtml
<ul>
  <li onclick="pick(this)">Red</li>
  <li onclick="pick(this)">Blue</li>
</ul>
Righthtml
<ul role="listbox" aria-label="Color" tabindex="0" aria-activedescendant="c1">
  <li role="option" id="c1" aria-selected="true">Red</li>
  <li role="option" id="c2" aria-selected="false">Blue</li>
</ul>

The list becomes a focusable listbox with option roles and selection state, ready for arrow key handling.

Common mistakes

  • Using role='listbox' for a plain list of links or cards.
  • Putting interactive elements, like delete buttons, inside options.

Key points

  • Every child of the listbox has role='option', and options contain no buttons or links.
  • Focus is managed with aria-activedescendant or roving tabindex, and arrow keys move it.
  • Selected options have aria-selected='true'; multi-select lists set aria-multiselectable='true'.
  • A native <select> is used when the design allows.

Interview questions

Does the select element have the listbox role?

Yes, when it has multiple or a size greater than 1. A single-choice dropdown <select> maps to combobox.

Can a listbox option contain a button?

No. Options cannot contain interactive elements; use a grid if each row needs its own controls.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy