docs.rodeo

MDN Web Docs mirror

ARIA: menuitem role

{{AccessibilitySidebar}} 

The menuitem role indicates the element is an option in a set of choices contained by a menu or menubar.

Description

A menuitem is one of the three types of options in a set of choices contained by a menu or menubar; the other two being menuitemcheckbox and menuitemradio. The menuitem is only found as a descendant of, or owned by, elements with role menu or menubar, optionally nested within an element with role group that is contained in, or owned by, a menu.

If the menuitem is not a descendant of a menu in the DOM, include the aria-owns attribute on menu to indicate the relationship. If aria-owns is set on the menu container to include elements that are not DOM children of the container, those elements will appear in the reading order in the sequence they are referenced and after any items that are DOM children in supporting technologies. Ensure the visual focus order matches the assistive technology reading order.

Every menuitem in a menu is focusable, whether or not it is disabled. Indicate a menuitem is disabled by setting aria-disabled="true" on the element with the role.

If a menuitem has a submenu, program it to display a new sub-level menu when the menu item is activated and include aria-haspopup="menu" or with the true value to indicate to assistive technologies that the menu item is used to open a submenu.

A common convention for indicating that a menuitem launches a dialog box is to append “…” (ellipsis) to the menu item label, e.g., “Save as …”.

Every menuitem must have an accessible name. This name comes from the element’s contents by default. If the contents don’t provide for a useful accessible name, aria-labelledby can be used to reference visible label. If no visible content is available to provide the accessible name, an accessible name can be provided with aria-label.

Associated WAI-ARIA roles, states, and properties

Keyboard interactions

If a menu is opened or a menu bar receives focus as a result of a context action, Escape or Enter may return focus to the invoking context.

Some implementations of navigation menubars may have menuitem elements that both perform a function and open a submenu. In such implementations, Enter and Space perform a navigation function while Down Arrow, in a horizontal menubar, opens the submenu associated with that same menuitem.

When items in a menubar are arranged vertically and items in menu containers are arranged horizontally the Down Arrow performs as Right Arrow is described above, the Up Arrow performs as Left Arrow is described above, and vice versa.

Examples

<div>
  <button id="menubutton" aria-haspopup="true" aria-controls="menu">
    <img src="hamburger.svg" alt="Page Sections" />
  </button>
  <ul id="menu" role="menu" aria-labelledby="menubutton">
    <li role="presentation">
      <a role="menuitem" href="#description">Description</a>
    </li>
    <li role="presentation">
      <a
        role="menuitem"
        href="#associated_wai-aria_roles_states_and_properties">
        Associated WAI-ARIA roles, states, and properties
      </a>
    </li>
    <li role="presentation">
      <a role="menuitem" href="#keyboard_interactions">
        Keyboard interactions
      </a>
    </li>
    <li role="presentation">
      <a role="menuitem" href="#examples">Examples</a>
    </li>
    <li role="presentation">
      <a role="menuitem" href="#specifications">Specifications</a>
    </li>
    <li role="presentation">
      <a role="menuitem" href="#see_also">See Also</a>
    </li>
  </ul>
</div>

Specifications

{{Specifications}} 

See also

In this article

View on MDN