Purpose
Expose grouped actions that relate to the same UI surface.
Loading ...
menuPresents a list of actions or commands. Menus often appear as context menus, dropdowns, or secondary command palettes.
Menu surface triggered by a button with Arrow key navigation and shortcuts.
Expose grouped actions that relate to the same UI surface.
Contains menuitem, menuitemcheckbox, or menuitemradio elements.
Often paired with a menu button that sets aria-expanded and focus management.
Right-click or long-press menus for file operations, editing, or row-level actions.
Buttons with adjacent caret toggles that show additional commands.
Rich text editors or design tools with multi-level command structures.
A button with aria-haspopup="menu" and aria-controls referencing the menu element.
role="menu" requires an accessible name and should stay mounted for assistive tech discovery.
Use role="menuitem", "menuitemcheckbox", or "menuitemradio". Apply aria-checked where relevant.
| Action | Keys | Result |
|---|---|---|
| Open menu | Enter / Space / ArrowDown | Opens the menu from its trigger and focuses the first item. |
| Move focus | ArrowDown / ArrowUp | Moves between items without closing the menu. |
| Jump to edges | Home / End | Moves to the first or last menu item. |
| Activate | Enter / Space | Runs the command for the focused item. |
| Close menu | Escape / Alt + ArrowUp | Dismisses the menu and returns focus to the trigger. |
| Submenu navigation | ArrowRight / ArrowLeft | Right opens a submenu when present; Left closes the current submenu. |
aria-orientationOptionalSet to vertical (default) or horizontal depending on layout.
aria-haspopupOptionalButtons or menu items that open submenus should advertize aria-haspopup="menu".
aria-controlsOptionalReference the id of the menu or submenu that a trigger controls.
aria-activedescendantOptionalOptional alternative to moving DOM focus. Useful when menu items contain inputs.
aria-checkedOptionalRequired for menuitemcheckbox or menuitemradio when representing toggled states.
Close the menu when focus leaves the menu container unless it moves into a submenu.
Trap focus inside an open menu by looping arrow navigation or returning focus to the trigger.
Support hover activation but never rely on hover alone—keyboard users must access every command.
Place menus adjacent to triggers in DOM order or manage aria-owns/aria-controls carefully.
Ensure submenus announce context (e.g., “Font Size submenu”) via aria-label.
Trigger button toggles aria-expanded and keeps focus inside the menu.
<button
id="menu-trigger"
aria-haspopup="menu"
aria-expanded="false"
aria-controls="file-menu"
>
File
</button>
<div id="file-menu" role="menu" aria-labelledby="menu-trigger" hidden>
<button role="menuitem">New File</button>
<button role="menuitem">Duplicate</button>
<button role="menuitem">Move to...</button>
<button role="menuitem" disabled>Delete</button>
</div>menuitem opens another role="menu" with ArrowRight.
<div role="menu" aria-label="Text formatting">
<button role="menuitemcheckbox" aria-checked="true">Bold</button>
<button role="menuitemcheckbox" aria-checked="false">Italic</button>
<div role="none" class="submenu-trigger">
<button
role="menuitem"
aria-haspopup="menu"
aria-controls="font-size-menu"
aria-expanded="false"
>
Font size
</button>
<div id="font-size-menu" role="menu" hidden>
<button role="menuitemradio" aria-checked="false">12px</button>
<button role="menuitemradio" aria-checked="true">14px</button>
<button role="menuitemradio" aria-checked="false">16px</button>
</div>
</div>
</div>Keep menus attached to the element that invoked them so assistive tech describes the relationship.
Adopt the same arrow, Escape, and Enter semantics that users expect from operating system menus.
Always return focus to the trigger when the menu closes, even if closed via pointer click.
Removing the menu from the accessibility tree between openings breaks aria-controls references.
Leave the menu in the DOM and toggle the hidden attribute or use visibility/opacity.
Using a list with no role prevents screen readers from switching to menu interaction mode.
Set role="menu" and apply menuitem roles to children.
Top-level horizontal navigation that owns menus.
Learn moreIndividual actionable item inside a menu.
Learn moreToggleable command inside a menu.
Learn moreMutually exclusive command inside a menu.
Learn more