Menu
A menu contains a collection of menu item commands.
Last updated
Was this helpful?
A menu contains a collection of menu item commands.
Last updated
Was this helpful?
A menu is appropriate when requiring a partial page re-render without using a form or full page reload. For example: filtering and sorting of search results.
If your menu must contain a mix of JavaScript behaviour and links behaviour, please use a list of buttons and links. Do no mix menu items and links.
menu: the pattern as a whole, comprising the parts listed below
command list: the list of menu items
command: the individual menu item, menu item checkbox or menu item radio commands
Remember, a menu is not a form control. Its purpose is not to store or submit data via form submission. A menu, like a button, is a mechanism to execute JavaScript, and therefore is 100% dependent on JavaScript.
If you are concerned that the functionality of the menu must be available in a non-JavaScript state, then perhaps a menu is not the best choice. Consider form controls instead.
Adding, modifying or deleting records (e.g. CRUD) could be considered critical functionality. Filtering and sorting search results could be considered non-critical.
Selecting a command must perform a JavaScript action on the client (e.g. AJAX request then partial page re-render).
This section provides interaction design for keyboard, screen reader & pointing devices.
The menu itself does not receive focus; focus must go to the first item in the menu.
UP-ARROW
and DOWN-ARROW
keys must navigate keyboard focus through commands via roving tabindex mechanism (skipping any that are disabled).
If focus is on a command, ENTER
or SPACEBAR
keys must activate that command.
TAB
key must move keyboard focus off menu, and onto next interactive element in the page.
Commands must be announced as "menu item", "menu item radio" or "menu item checkbox" role.
Checkbox and radio command state must be announced as checked or unchecked.
Disabled commands must be announced as disabled.
Clicking any menu item must activate that command.
We have some JavaScript modules that may assist you with creation of an accessible menu widget:
This section gives an overview of our use of ARIA, within the specific context of the menu pattern.
Informs assistive technology that this is a menu containing menuitems, menuitemradios or menuitemcheckboxes.
Informs assistive technology that the divs around groups of menu items are for presentation purposes only and should not be added to accessibility tree.
Informs assistive technology that this menu command has button behaviour.
Informs assistive technology that this menu command has radio button behaviour.
Informs assistive technology that this menu command has checkbox behaviour.
Informs assistive technology whether the menuitemradio or menuitemcheckbox is checked or not. Notice we do not use aria-selected.
A menu may contain , or commands.
A menu is not appropriate for a full page reload. For that, please use links instead (see the pattern). The distinction between menu items and links is important! A menu item is a command that executes JavaScript, whereas a link is a command that navigates to a url.
Experience the pattern in action on our companion .
on .
View a fully styled example in our .
On desktop, a menu is typically opened with a . On mobile it is common to see a menu embedded directly inside of a filter or refine panel.
Selecting a command should not fully reload the page (use a instead).
Please see the pattern pattern. A menu is identical except for the lack of a button.
- Useful for implementing the arrow key behaviour to change menu items