Menu
Directive for creating a material designed menu. The menu can either be positioned manually, or automatically, by anchoring it to an element.
Accessibility
This directive will automatically apply proper accessibility attributes to the contained list, and its items:
- All list items will be assigned
role="menuitem", and atabindex="0"attributes. - Disabled menu items (use
disabledon the item), will be assigned:aria-disabled="true", andtabindex="-1". - The list itself will be assigned the
role="menu"attribute.
API
Directive: MdcMenuDirective
Selector:
[mdcMenu]
[mdcSelectMenu]
Exported as:
mdcMenu
Directive for a spec aligned material design Menu.
This directive should wrap an mdcList. The mdcList contains the menu items (and possible separators).
An mdcMenu element will also match with the selector of the menu surface directive, documented
here: mdcMenuSurface. The
mdcMenuAnchor API is documented on the same page.
Accessibility
- For
roleandaria-*attributes on the list, see documentation formdcList. - The best way to open the menu by user interaction is to use the
mdcMenuTriggerdirective on the interaction element (e.g. button). This takes care of following ARIA recommended practices for focusing the correct element, and maintaining properaria-*androleattributes on the interaction element, menu, and list. - When opening the
mdcMenuSurfaceprogrammatic, the program is responsible for all of this. (including focusing an element of the menu or the menu itself). - The
mdcListwill be made focusable by setting a"tabindex"="-1"attribute. - The
mdcListwill get anaria-orientation=verticalattribute. - The
mdcListwill get anaria-hidden=trueattribute when the menu surface is closed.
| Property | Description |
|---|---|
@Output()
pick
EventEmitter<MdcMenuSelection>
|
Event emitted when the user selects a value. The passed object contains a value
(set to the |
Directive: MdcMenuTriggerDirective
Selector: [mdcMenuTrigger]
Accessibility
Enter,Space, andDown Arrowkeys open the menu and place focus on the first item.Up Arrowopens the menu and places focus on the last itemClick/Touch events set focus to the mdcList root element
Attribute
role=buttonwill be set if the element is not already a button element.Attribute
aria-haspopup=menuwill be set if anmdcMenuis attached.Attribute
aria-expandedwill be set while the attached menu is openAttribute
aria-controlswill be set to the id of the attached menu. (And a unique id will be generated, if none was set on the menu).Enter,Space, andDown-Arrowwill open the menu with the first menu item focused.Up-Arrowwill open the menu with the last menu item focused.Mouse/Touch events will open the menu with the list root element focused. The list root element will handle keyboard navigation once it receives focus.
| Property | Description |
|---|---|
@Input()
mdcMenuTrigger
MdcMenuDirective
|
Interface: MdcMenuSelection
Data send by the pick event of MdcMenuDirective.
| Property | Description |
|---|---|
value
any
|
The |
index
number
|
The index of the selected menu item ( |