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.

Also known as: Cascading Menu
Salt package@salt-ds/core
Available since1.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 Dropdown to pick from a short list, or ComboBox to type and filter a long list.
  • When a selectable MenuGroup has no label, pass an aria-label that 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.
KeyFunction
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
  • If focus is on the menu trigger, this action opens the menu and places focus on the first menu item.
  • When focus is on a menu item that has a submenu, this action opens the submenu and places focus on its first item.
  • When focus is on a menu item in a selectable MenuGroup, this action selects the item, or toggles it when the group allows multiple selection, and closes the menu.
  • Otherwise, this action activates the item, and closes the menu.
Space
  • If focus is on the menu trigger, this action opens the menu and places focus on the first menu item.
  • When focus is on a menu item that has a submenu, this action opens the submenu and places focus on its first item.
  • When focus is on a menu item in a selectable MenuGroup, this action selects the item, or toggles it when the group allows multiple selection. The menu remains open, so users can review or change their selection.
  • Otherwise, this action activates the item, and closes the menu.
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.