A dropdown menu allows the user to choose an option or action from a contextual list. The source of the dropdown is usually a button.
Dropdown menus present a list of options that take an immediate action or navigate the user outside of the current context.
Dropdown menus present a list of options that take an immediate action or navigate the user outside of the current context.
Select boxes present a list of options that the user can choose from and apply to an input field.
Use a button for the toggle. The button can contain either text or an icon plus text.
Keep the text for menu items short and concise. Long menu items are truncated from the end and an ellipsis added.
Order menu items by usage, except for destructive actions, which belong at the bottom.
Headers and dividers can be used to organize a longer list of items.
Clicking on the toggle (button) opens the dropdown.
By default, selecting a menu item or clicking outside the menu dismisses the menu. You can change this behavior to keep the menu open on item selection
By default, a dropdown opens from the bottom of the toggle, along the left side. You can change the placement by using one of the eight direction classes.
Items in the dropdown menu have hover and click states.
Nested menus are an extension of dropdown menus. They save screen space by organizing a long list of items into categories that the user can click to reveal deeper levels.
The best practice is to limit menus to three levels, which would be the root menu plus up to two levels of nested menus.
With a mouse, the user clicks a category menu item to reveal a nested menu. The category (or group) name stays in selected state to serve as a breadcrumb.
Clicking outside the menu dismisses all menus.
By default, a nested menu pops up on the right side of its root menu.
If screen space isn’t available to the right of the root menu, the nested menu appears on the left side. If there is a second nested menu, it appears to the right of the first nested menu, creating a zig-zag pattern.
Clarity Angular component follows these guidelines:
button
that opens the menu. button
role should also have an aria-expanded
attribute which is set to true when the dropdown menu is open. menu
, and have the role menuitem
. separator
can be used between groups of items within a menu. The separator can not receive input focus and is not interactive. aria-hidden
attribute set to true
. disabled
attribute so disabled items can receive input focus. Instead, use [clrDisabled]
to add the disabled visual style and ARIA attribute when needed. Status Type | Sample |
---|---|
Enter, Space, Down Arrow on the menu button | Opens the menu and focuses on the first item |
Up Arrow on menu | Focus on the previous item, or the last item if currently on the first one |
Down Arrow on menu | Focus on the next item, or the first item if currently on the first one |
Right Arrow on a menu item with submenu | Opens the submenu and focuses on the first item |
Left Arrow on a submenu | Closes the submenu and focuses on its parent item |
Esc | Closes the menu and focuses on the trigger (in the case of submenu the trigger is its parent item). |