Actions Menu Button Example
This example implements the menu button design pattern
for a button that provides access to a menu of actions.
When an element with role button
has aria-haspopup="true"
,
browsers inform assistive technologies that the button is a menu button.
This role transformation caused by aria-haspopup
happens with any element that is recognized as a button,
including the HTML button
and input[type="button"]
elements.
Similar examples include:
- Navigation Menu Button: The popup menu items are
a
elements and act as links.
Example
This example shows a popup menu of actions that can be used for changing states in a web application.
Keyboard Support
Menu Button
Key | Function |
---|---|
Down Arrow, Space, or Enter |
Open menu and move focus to first menuitem |
Up Arrow Key | Open menu and move focus to previous menuitem |
Popup Menu Widget
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
|
button
|
|
|
|
aria-haspopup="true" |
button
|
|
|
aria-controls="IDREF" |
button
|
|
aria-expanded="true" |
button |
|
|
aria-expanded="false" |
button |
|
Popup Menu
Role | Attribute | Element | Usage |
---|---|---|---|
menu
|
ul
|
|
|
|
aria-labelledby="[IDREF]" |
ul
|
|
menuitem
|
li
|
|
|
|
tabindex="-1" |
li
|
|
Javascript and CSS Source Code
- CSS: MenubuttonAction.css
- Javascript: Menubutton.js
- Javascript: MenuItemAction.js
- Javascript: PopupMenuAction.js