Navigation Menubar Example - adopted from Mega menu
NOTE: This is based off the ARIA Practices example menu to show how it might be adopted as a horizontal mega menu that has heading columns. The CSS of course is just mock up. This is only for showing the ARIA roles states, properties, HTML and JavaScript keyboard behavior.
The following implementation of the design pattern for menubar demonstrates a menubar that provides site navigation menus. Each item in the menubar represents a section of a web site for a mythical university and opens a submenu containing menu items that link to pages within that section.
Similar examples include:
- Editor Menubar Example: Example of a menubar that presents text styling actions similar to an editor application.
Example
Accessibility Features
- Since the menubar presents a site navigation system, it is wrapped in a navigation region implemented with a
nav
element that has anaria-label
that matches the label on the menubar. - The down arrow and right arrow icons are made compatible with high contrast mode and hidden from screen readers by using the CSS
content
property to render images.
Keyboard Support
Menubar
Key | Function |
---|---|
Space Enter |
Opens submenu and moves focus to first item in the submenu. |
Right Arrow |
|
Left Arrow |
|
Down Arrow | Opens submenu and moves focus to first item in the submenu. |
Up Arrow | Opens submenu and moves focus to last item in the submenu. |
Home | Moves focus to first item in the menubar. |
End | Moves focus to last item in the menubar. |
Character |
|
Submenu
Key | Function |
---|---|
Space Enter |
|
Escape |
|
Right Arrow |
|
Left Arrow |
|
Down Arrow |
|
Up Arrow |
|
Home | Moves focus to the first item in the submenu. |
End | Moves focus to the last item in the submenu. |
Character |
|
Accessibility Features
- Since the menubar presents a site navigation system, it is wrapped in a navigation region implemented with a
nav
element that has anaria-label
that matches the label on the menubar. - The down arrow and right arrow icons are made compatible with high contrast mode and hidden from screen readers by using the CSS
content
property to render images.
Keyboard Support
Menubar
Key | Function |
---|---|
Space Enter |
Opens submenu and moves focus to first item in the submenu. |
Right Arrow |
|
Left Arrow |
|
Down Arrow | Opens submenu and moves focus to first item in the submenu. |
Up Arrow | Opens submenu and moves focus to last item in the submenu. |
Home | Moves focus to first item in the menubar. |
End | Moves focus to last item in the menubar. |
Character |
|
Submenu
Key | Function |
---|---|
Space Enter |
|
Escape |
|
Right Arrow |
|
Left Arrow |
|
Down Arrow |
|
Up Arrow |
|
Home | Moves focus to the first item in the submenu. |
End | Moves focus to the last item in the submenu. |
Character |
|
Role, Property, State, and Tabindex Attributes
Menubar
Role | Attribute | Element | Usage |
---|---|---|---|
menubar
|
ul
|
|
|
aria-label="string"
|
ul
|
|
|
menuitem
|
a
|
|
|
tabindex="-1"
|
a
|
Makes the a element keyboard focusable, but not part of the tab sequence.
|
|
tabindex="0"
|
a
|
|
|
aria-haspopup="true"
|
a
|
Indicates the menuitem has a submenu. | |
aria-expanded="true"
|
a
|
Indicates the submenu is open. | |
aria-expanded="false"
|
a
|
Indicates the submenu is closed. | |
none
|
li
|
|
Submenu
Role | Attribute | Element | Usage |
---|---|---|---|
menu
|
ul
|
Identifies the element as a menu container for a set of menu items. | |
aria-label="string"
|
ul
|
|
|
menuitem
|
a
|
|
|
tabindex="-1"
|
a
|
Keeps the a element focusable but removes it from the Tab sequence. |
|
aria-haspopup="true"
|
a
|
Indicates the menu item has a submenu. | |
aria-expanded="true"
|
a
|
Indicates the submenu is open. | |
aria-expanded="false"
|
a
|
Indicates the submenu is closed. | |
none
|
li
|
|
Javascript and CSS Source Code
- CSS: menubarLinks.css
- Javascript: MenubarItemLinks.js
- Javascript: MenubarLinks.js
- Javascript: PopupMenuItemLinks.js
- Javascript: PopupMenuLinks.js
HTML Source Code