third_party/aria-practices/src/content/patterns/disclosure/examples/disclosure-navigation.html
Although this example uses the word "menu" in the colloquial sense to refer to a set of navigation links, it does not use the WAI-ARIA menu role. This implementation of site navigation does not use the menu role because it does not provide the complex functionality that assistive technologies expect in a widget that has the menu role. Typical site navigation does not need all the keyboard interactions specified by the menu and menubar pattern.
The following example demonstrates using the Disclosure Pattern to show and hide dropdown lists of links in a navigation bar for a mythical university web site. Each disclosure button represents a section of the web site, and expanding it shows a list of links to pages within that section.
Similar examples include:
This example demonstrates two different ways of implementing keyboard support. Toggle between them with the following checkbox.
Include optional support for arrow keys, Home, and End
Sample content section. Activating a link above will update and navigate to this region.
::after pseudo element border styles so the caret is reliably rendered in high contrast mode of operating systems and browsers.grid, that is expected to occupy only one stop in the page Tab sequence and manage focus for all its descendants.| Key | Function |
|---|---|
| Tab | |
| Shift + Tab | Move keyboard focus among top-level buttons, and if a dropdown is open, into and through links in the dropdown. |
| Space or | |
| Enter |
aria-current set, removes it.aria-current="page" on the focused link.|
| Escape | If a dropdown is open, closes it and sets focus on the button that controls that dropdown. |
| Down Arrow or
Right Arrow
(Optional) |
|
| Up Arrow or
Left Arrow
(Optional) |
| | Home (Optional) |
| | End (Optional) |
|
| Role | Attribute | Element | Usage |
|---|---|---|---|
aria-controls="IDREF" | button | The disclosure button controls visibility of the container identified by the IDREF value. | |
aria-expanded="false" | button |
[aria-expanded="false"]) are used to synchronize the visual states with the value of the aria-expanded attribute.|
| | aria-expanded="true" | button |
[aria-expanded="true"]) are used to synchronize the visual states with the value of the aria-expanded attribute.|
| | aria-current="page" | a | Indicates that the page referenced by the link is currently displayed. |
Learn how to interpret and use assistive technology support data
To copy the following HTML code, please open it in CodePen.