ARIA Menu Button Example: Button Element
Authoring Practice Design Patten for Menu Button
Menu Button Example: Menu Button is an button element
Accessibility Features
- The
aria-haspopup="true"attribute on thebuttonelement identifies that activating the button will result in either a menu or dialog box opening. - The
aria-controlsattribute on thebuttonelement idenfities the content that will be opened when the button is activated. - The
role="menu"attribute on theulelement identifies the element as a contatiner for a list of menu items. - The
aria-labelledbyattribute of theul[role=menu]elements defines an accessible name for the menu. - The
role="menuitem"on thelielements identifies the element as a item in the menu . - The child text content of the
li[role=menuitem]elements defines the accessible name for each of the menu items. - The
button[aria-haspopup=true]element has akeydownevent to handle opening and closing the menu and moving focus to the menu. - Each of the
li[role=menuitem]elements has akeydownevent to handle navigation between menu items, closing the menu and activating the function of the menu item. - Each of the
li[role=menuitem]element has afocusevent to handle highlighting the menu item with keyboard focus.
Keyboard Support
Menu Button
| Key | Function |
|---|---|
| Space or Enter Key | Open menu and move focus to first menu item |
| Up Arrow Key | Open menu and moves focus to last menu item |
| Down Arrow Key | Open menu and moves focus to first menu item |
Menu
| Key | Function |
|---|---|
| Space or Enter Keys |
|
| Up or Left Arrow Key | Move focus to previous menu item |
| Down or Right Arrow Key | Move focus to next menu item |
| Escape Key | Close menu and move focus back to menu button |
ARIA Roles, Properties and States
| Role | Property/State | Usage |
|---|---|---|
menu |
Identifies the ul element as a menu widget |
|
menuitem |
Identifies the li element as a menu item widget |
|
aria-haspopup |
Identifies the button element as a menu button widget when the value is true |
|
aria-controls |
Identfies the content on the page (e.g. using IDREFs) that this menu button controls | |
aria-labelledby |
Use to provide a label the menu widget |