Menubar
2 Menubar variations from the W3C ARIA Authoring Practices Guide.
Menubar (Editor)
An editor menubar applies formatting to editable text. Checkboxes control independent styles; radio items select alignment and font. Size commands demonstrate focusable disabled items.
Example
Font size 16 pixels.
Keyboard interaction
Use Left/Right, Home/End, or a label character in the menubar. Down/Up opens the first/last menu item. In a submenu, Up/Down navigates, Right opens a nested menu, Left returns, and Escape closes. Enter or Space activates. Space changes a checkbox or radio while keeping its menu open; Enter changes it and closes the menu. Disabled items remain discoverable.
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 role="menubar" aria-label="Text formatting">
<button>Style</button>
<div id="style-menu" role="menu">
<button role="menuitemcheckbox" value="bold">Bold</button>
<button role="menuitemcheckbox" value="italic">Italic</button>
<button role="menuitemcheckbox" value="underline">Underline</button>
</div>
<button>Alignment</button>
<div id="align-menu" role="menu">
<button role="menuitemradio" value="left" aria-checked="true">Left</button>
<button role="menuitemradio" value="center">Center</button>
<button role="menuitemradio" value="right">Right</button>
</div>
<button>Font</button>
<div id="font-menu" role="menu">
<button role="menuitemradio" value="sans-serif" aria-checked="true">Sans serif</button>
<button role="menuitemradio" value="serif">Serif</button>
<button role="menuitemradio" value="monospace">Monospace</button>
</div>
<button>Size</button>
<div id="size-menu" role="menu">
<button value="smaller">Smaller</button>
<button value="larger">Larger</button>
</div>
</div>
<p>
<label for="editor-text">Editable text</label>
</p>
<textarea id="editor-text" data-editor rows="6" cols="50">Accessible interfaces support different ways of reading, writing, and navigating. Try the formatting commands above, then continue editing here.</textarea>
<p role="status" data-editor-status>Font size 16 pixels.</p>
</axxy-scope>Menubar (Navigation)
A university navigation menubar with nested departments. Selecting a destination updates the content heading and moves focus there.
Example
Home
Choose a university section from the navigation.
Keyboard interaction
Use Left/Right, Home/End, or a label character in the menubar. Down/Up opens the first/last menu item. In a submenu, Up/Down navigates, Right opens a nested menu, Left returns, and Escape closes. Enter or Space activates.
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>
<nav aria-label="University">
<ul role="menubar" aria-label="University">
<li>
<a href="#destination">Home</a>
</li>
<li>
<button>
About
<span aria-hidden="true">▾</span>
</button>
<ul role="menu">
<li>
<a href="#destination">History</a>
</li>
<li>
<a href="#destination">Leadership</a>
</li>
</ul>
</li>
<li>
<button>
Study
<span aria-hidden="true">▾</span>
</button>
<ul role="menu">
<li>
<a href="#destination">Admissions</a>
</li>
<li>
<button>
Departments
<span aria-hidden="true">▸</span>
</button>
<ul role="menu">
<li>
<a href="#destination">Engineering</a>
</li>
<li>
<a href="#destination">Literature</a>
</li>
<li>
<a href="#destination">Sciences</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<section>
<h2 id="destination" data-navigation-heading tabindex="-1">Home</h2>
<p data-navigation-body>Choose a university section from the navigation.</p>
</section>
</axxy-scope>