Select
An exposed dropdown menu: a field that opens a menu of options. One or several choices, sections, a search for long lists, a sheet on phones.
import { Select, SelectItem, SelectSection, OptionPopover } from '@windmorph/react';Keyboard
| Key | Action | Where |
|---|---|---|
| Enter or Space or Arrow Down | Opens the menu, with focus on the chosen option or else the first.On the field | On the field |
| Arrow Up | Opens the menu, with focus on the chosen option or else the last.On the field | On the field |
| Arrow Left or Arrow Right | Chooses the previous or next option without opening the menu (single selection).On the field | On the field |
| A letter | Chooses the next option starting with it without opening the menu, as a native select does (single selection).On the field | On the field |
| Arrow Up or Arrow Down | Moves between the options, wrapping at the ends.In the menu | In the menu |
| Home or End | Moves to the first or last option.In the menu | In the menu |
| A letter | Moves to the next option starting with it; the same letter again moves on.In the menu | In the menu |
| Enter or Space | Chooses the focused option and closes the menu. With selectionMode="multiple" it adds or removes the option and the menu stays open.In the menu | In the menu |
| Escape | Closes the menu.In the menu | In the menu |
| Arrow Up or Arrow Down | Moves through the matching options while focus stays in the search.Searchable | Searchable |
| Enter | Chooses the highlighted option.Searchable | Searchable |
| Escape | Clears the search, then closes the menu or sheet.Searchable | Searchable |
- Typeahead wraps around to the top of the list.
- A
readOnlyfield opens no menu, and the arrow keys and typeahead don't change its value.
Screen reader
- Role
- The field is a
buttonwitharia-haspopup(listbox, ordialogwhensearchable) andaria-expanded. The options are alistboxofoptions, ingroups under their headings when there are sections. Asearchablemenu is adialogholding a searchcombobox(aria-activedescendant) over the listbox. - Accessible name
- The field is named by its
label(with a*whenrequired) and its value; without a label, byaria-labelledby(a heading above it) oraria-label. Given together, they join (alabelwitharia-labelledbytoo). The listbox, the search dialog and the bottom sheet take the same name. The search input is named "Search" (labels.search). - States announced
- Selected or not on each option (
aria-selected),aria-multiselectablewith multiple selection and disabled options (aria-disabled). The field is a button, which ARIA doesn't let carryaria-invalidoraria-required, so a required field says so with the*in its name, and an invalid one with its error text, in its description and announced as an alert.
- Supporting text is the field's description. An error message replaces it visually and is announced as an alert, while the supporting text stays in the description. An invalid field shows an error icon (
img) named "Error" (labels.error). - With
renderValuethe field shows what you render (a code, a flag) hidden from assistive tech, while screen readers still hear the chosen options' text. - With several options chosen the field reads the first two and a count, "+3" (
labels.more). - An empty list shows a
statusthat is announced: "No options" (labels.empty), or "No results" (labels.noResults) when a search matches nothing. Whileloading, the list ends in aprogressbarnamed "Loading options" (labels.loading). - Option icons, the check on chosen options, trailing text and the dropdown arrow are hidden from assistive tech.
- An
aria-invalidoraria-requireda form library sets is read asinvalidorrequiredwhen those are left out.aria-descriptionand the braille labels reach the field's button; the field sets its own popup attributes (aria-haspopup,aria-expanded,aria-controls).
Focus
- Disabled options take keyboard focus but can't be chosen, as M3 asks of menu items. Options past
maxSelectionsare disabled the same way until one is removed. - While the menu is open the rest of the page is hidden from assistive tech. Choosing an option or Escape closes it and returns focus to the field; a press outside closes it and lets focus go, as it would leave any other field.
- A
searchablemenu puts focus in its search. A searchable bottom sheet shows the list first, so the on-screen keyboard doesn't cover it, and a tap on the search starts typing. - The field shows focus as a text field does: its indicator line or border thickens to 2px and takes the focus colour. Options show M3's focus indicator drawn inside the row.
Touch target
- The field is at least 56px tall and opens from a press anywhere on it, with a mouse or a finger.
- Options are M3's 44px menu rows, spanning the list's width, and stacked with no gap, so they have no extra touch target; the search field in a
searchablemenu is 48px tall.
Motion
- Under reduced motion the menu only fades in and out, without the reveal from the field's edge, and the dropdown arrow turns over without rotating.
- In a
searchablelist, options that stay after filtering ease into their new places; under reduced motion they jump.
What you need to do
- Give the field a visible
label, or anaria-labelwhen there is none. - Pass
textValueon an option whose content is not plain text, so typeahead, filtering and the field's value can read it. - Translate the built-in words with
labels: "No options", "Loading options", "Search", "No results", "Error" and the "+N" count. - Use
presentation="auto"or"sheet"for long lists on phones, andsearchablewhen people know what they are looking for.