Menu
Menu is a container that presents a selection of choices or actions from which to choose. The user opens it with a customizable trigger, such as an interactive button, or an interaction, such as a keyboard shortcut or mouse right-click.
| Salt package | @salt-ds/core |
|---|---|
| Available since | 1.27.0 |
- Use a menu for a list of actions or commands, such as "More actions".
- Use selectable menu items when those actions include a stateful choice that users can set and revisit, such as a mode, view options or a sort order.
- Avoid selectable menu items when the list is really a value picker for a form control, such as choosing a year or country. Instead, use
Dropdownto pick from a short list, orComboBoxto type and filter a long list. - When a selectable
MenuGrouphas nolabel, pass anaria-labelthat describes the set of options, so screen reader users know what they're choosing between.
- Disabled menu items remain focusable, so keyboard and screen reader users can still discover them. For further information, see the W3C guidance on focusability of disabled controls.
| Key | Function |
|---|---|
| Tab | If focus is on a menu item, Tab closes the menu and moves focus to the next focusable element in the tab order. |
| Shift + Tab | If focus is on a menu item, this action closes the menu and moves focus to the previous focusable element in the tab order. |
| Enter |
|
| Space |
|
| Up arrow | When focus is in a menu, Up arrow moves focus to the previous item. |
| Down arrow | When focus is in a menu, Down arrow moves focus to the next item. |
| Right arrow | When focus is in a menu and on a menu item that has a submenu, Right arrow opens the submenu and places focus on its first item. |
| Left arrow | When focus is in a submenu of an item in a menu, Left arrow closes the submenu and returns focus to the parent menu item. |
| Escape | Escape closes the menu, and sets focus to the element element that triggered opening the menu, e.g. a button or the parent menu item from which the menu was opened. |