Menu Button
3 Menu Button variations from the W3C ARIA Authoring Practices Guide.
Menu Button (Actions, activedescendant)
The actions menu keeps DOM focus on the menu container and identifies the active item with aria-activedescendant.
Example
Keyboard interaction
Enter, Space, or Down Arrow opens a menu; Up Arrow opens at its last item. Use Up/Down, Home/End, or type a label to navigate. Escape returns to the opener; Tab leaves the menu.
Events
Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.
axxy-menu-select— Dispatched when a menu item is activated. Calling preventDefault() suppresses default navigation. (target:[role="menuitem"], detail:{ item: HTMLElement, value: string, checked: string|null }, cancelable)
Example HTML
<axxy-scope>
<div>
<button>
Actions
<span aria-hidden="true">▾</span>
</button>
<ul role="menu" tabindex="-1">
<li>
<button>Copy</button>
</li>
<li>
<button>Delete</button>
</li>
<li>
<button>Move</button>
</li>
<li>
<button>Rename</button>
</li>
</ul>
</div>
<p>
<label>
Last action
<input data-last-action readonly value="No action selected">
</label>
</p>
<button type="button">Continue</button>
</axxy-scope>Menu Button (Actions, focus)
An actions menu moves DOM focus to each menu item. Activating an item records the action and returns focus to its button.
Example
Keyboard interaction
Enter, Space, or Down Arrow opens a menu; Up Arrow opens at its last item. Use Up/Down, Home/End, or type a label to navigate. Escape returns to the opener; Tab leaves the menu.
Events
Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.
axxy-menu-select— Dispatched when a menu item is activated. Calling preventDefault() suppresses default navigation. (target:[role="menuitem"], detail:{ item: HTMLElement, value: string, checked: string|null }, cancelable)
Example HTML
<axxy-scope>
<div>
<button>
Actions
<span aria-hidden="true">▾</span>
</button>
<ul role="menu" >
<li>
<button>Copy</button>
</li>
<li>
<button>Delete</button>
</li>
<li>
<button>Move</button>
</li>
<li>
<button>Rename</button>
</li>
</ul>
</div>
<p>
<label>
Last action
<input data-last-action readonly value="No action selected">
</label>
</p>
<button type="button">Continue</button>
</axxy-scope>Menu Button (Navigation)
A menu button presents links with native link context menus. This example renders local destinations and focuses the updated heading.
Example
Resources
Choose a resource.
Keyboard interaction
Enter, Space, or Down Arrow opens a menu; Up Arrow opens at its last item. Use Up/Down, Home/End, or type a label to navigate. Escape returns to the opener; Tab leaves the menu.
Events
Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.
axxy-menu-select— Dispatched when a menu item is activated. Calling preventDefault() suppresses default navigation. (target:[role="menuitem"], detail:{ item: HTMLElement, value: string, checked: string|null }, cancelable)
Example HTML
<axxy-scope>
<div>
<button>
Resources
<span aria-hidden="true">▾</span>
</button>
<ul role="menu">
<li>
<a href="#destination">Accessibility basics</a>
</li>
<li>
<a href="#destination">Design patterns</a>
</li>
<li>
<a href="#destination">Testing resources</a>
</li>
</ul>
</div>
<h2 id="destination" data-navigation-heading tabindex="-1">Resources</h2>
<p data-navigation-body>Choose a resource.</p>
</axxy-scope>