On this page

Command

Keys, what Command gives you and what your team does.

Conformance

Command meets WCAG 2.2 level AA when used as described on these pages. It follows the Listbox pattern of the WAI-ARIA Authoring Practices, with focus kept in the search field.

Keyboard

Key Action
Typing Filters the list.
Down, Up Move the highlight through the items.
Home, End Move to the first or last item.
Enter Runs the highlighted item.
Esc In CommandDialog, closes the palette. Focus goes back to where it was.

What Command gives you

  • role="listbox" on the list and role="option" on items; groups are named by their heading.
  • The search field points at the highlighted item (aria-activedescendant), so screen readers read it while focus stays in the field.
  • CommandDialog is a modal dialog with a title and a description, even though they are not shown.

What your team does

  • Give every CommandInput a placeholder or a label that says what can be searched.
  • Set the CommandDialog title and description in the page’s language.
  • If a keyboard shortcut opens the palette, show it on the button that opens it and set aria-keyshortcuts, as the example does.
  • Don’t take a shortcut the browser or screen readers use.

WCAG criteria

Criterion Level How
1.3.1 Info and Relationships A Listbox, options and named groups
2.1.1 Keyboard A Typing, arrow keys and Enter
2.1.4 Character Key Shortcuts A The palette shortcut uses Ctrl, not a single letter
4.1.2 Name, Role, Value A role="listbox", aria-activedescendant, aria-selected
4.1.3 Status Messages AA Your team: announce the number of results if the list changes a lot