third_party/aria-practices/src/content/patterns/menu-button/examples/menu-button-actions-active-descendant.html
This example demonstrates how the Menu Button Pattern can be used to create a button that opens an actions menu. In this example, choosing an action from the menu will cause the chosen action to be displayed in the Last Action edit box.
This implementation manages focus in the menu as described in the section on Managing Focus in Composites Using aria-activedescendant.
Similar examples include:
element.focus().Actions
Last Action:
currentcolor value for the fill and stroke properties of the SVG polygon element is used to synchronize the color with text content. If specific colors are used to specify the fill and stroke properties, these colors will remain the same in high contrast mode, which could lead to insufficient contrast between the icon and the background or even make the icon invisible if its color matches the high contrast mode background.| Key | Function |
|---|---|
| Down Arrow | |
| Space | |
| Enter | Opens menu and moves focus to first menuitem |
| Up Arrow | Opens menu and moves focus to last menuitem |
| Key | Function |
|---|---|
| Enter |
| | Escape |
| | Up Arrow |
| | Down Arrow |
|
| Home | Moves focus to the first menu item. |
| End | Moves focus to the last menu item. |
| A-Z
a-z |
|
| Role | Attribute | Element | Usage |
|---|---|---|---|
aria-haspopup="true" | button |
button element opens a menu.aria-haspopup set to either true or menu as menu buttons.|
| | aria-controls="ID_REFERENCE" | button |
|
| | aria-expanded="false" | button | Indicates the menu is not displayed and that activating the menu button opens the menu. |
| | aria-expanded="true" | button | Indicates the menu is displayed and that activating the menu button closes the menu. |
| Role | Attribute | Element | Usage |
|---|---|---|---|
menu | ul | Identifies the ul element as a menu. | |
| `` | aria-labelledby="ID_REFERENCE" | ul |
menu.|
| | tabindex="-1" | ul |
|
| | aria-activedescendant="ID_REFERENCE" | ul |
menuitem element that is visually indicated as focused.ID_REFERENCE value is updated when keys that move the focus indicator among menu items are pressed.ul element with role menu.|
| menuitem | | li |
li element as a menuitem.li element provides the accessible name of the menuitem.|
Learn how to interpret and use assistive technology support data
To copy the following HTML code, please open it in CodePen.