Navigation Menu Button Example
This example implements the menu button design pattern
for a button that provides access to a menu of link targets.
An ARIA menu button is defined as any element with role="button"
with an aria-haspopup="true"
.
In this example the default role of link for the a
element is overridden using role="button"
to define the menu button. It is also important to note in the popup menu that the role=menuitem
is on the
a
element and not the li
element, since a menuitem
widget cannot contain any intereactive elements (e.g links).
Similar examples include:
- Action Menu Button: The popup menu items can be used to activate actions in a web application.
Example
Keyboard Support
Menu Button
Key | Function |
---|---|
Down Arrow, Space, or Enter |
Open menu and move focus to first menuitem |
Up Arrow | Open menu and move focus to previous menuitem |
Popup Menu
Key | Function |
---|---|
Space or Enter |
|
Escape |
|
Up Arrow |
|
Down Arrow |
|
Home |
|
End |
|
A-Z, a-z |
|
Role, Property, State, and Tabindex Attributes
Menu Button Widget
Role | Attribute | Element | Usage |
---|---|---|---|
button
|
a
|
|
|
|
href="#" |
a
|
|
|
aria-haspopup="true" |
a
|
|
|
aria-controls="IDREF" |
a
|
|
aria-expanded="true" |
a |
|
|
aria-expanded="false" |
a |
|
Popup Menu Widget
Role | Attribute | Element | Usage |
---|---|---|---|
menu
|
ul
|
|
|
|
aria-labelledby="[IDREF]" |
ul
|
|
menuitem
|
a
|
|
|
|
tabindex="-1" |
a
|
|
none
|
li
|
|
Javascript and CSS Source Code
- CSS: MenubuttonLinks.css
- Javascript: Menubutton.js
- Javascript: MenuItemLinks.js
- Javascript: PopupMenuLinks.js