Menu Item
lightning:menuItem
Represents a list item in a menu.
For Aura components only. For LWC development, use lightning-menu-item.
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline
A lightning:menuItem is a menu item within the lightning:buttonMenu dropdown component. It can hold state such as checked or unchecked, and can contain icons.
Use the class attribute to customize the styling.
This component implements styling from menus in the Lightning Design System.
When applying Lightning Design System classes or icons, check that they are available in the Lightning Design System release tied to your org. The Lightning Design System site shows the latest Lightning Design System resources, and these become available only when the new release is available in your org.
Here is an example.
To implement a multi-select menu, use the checked attribute. The following client-side controller example handles selection via the onselect event on the lightning:buttonMenu component. Selecting a menu item applies the selected state to that item.
Use the iconName attribute to add an icon after the text of the menu item. Use the prefixIconName attribute to add an icon before the text of the menu item. For each attribute, specify a utility icon from utility icons in Lightning Design System.
This example specifies an icon to display before the menu item text.
The href attribute allows you to use the button menu for navigation. This example specifies a URL in the menu item's href attribute to create a link. The link is applied to the content of the menu item, including text and icons.
Use the isDraft and draftAlternativeText attributes together to indicate that the menu item is in an unsaved state. The draft indicator, an asterisk, is shown for the menu item when isDraft is true. The draftAlternativeText attribute is required to provide text describing the reason the item is considered in a draft state. The draft state might be used to to show there is unsaved state or data that could be lost, for example if there's a user change in a customizable menu.