MenuItem

The <MenuItem> component represents an item in a menu.

NOTE

This component is supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Child Components

Not supported

APIs

MenuItem(value?: MenuItemOptions| CustomBuilder)

Parameters

Name Type Mandatory Description
value MenuItemOptions | CustomBuilder No Information about the menu item.
Name Type Mandatory Description
startIcon ResourceStr No Path to the icon displayed on the left of the menu item.
content ResourceStr Yes Content of the menu item.
endIcon ResourceStr No Path to the icon displayed on the right of the menu item.
labelInfo ResourceStr No Information about the ending label, for example, shortcut Ctrl+C.
builder CustomBuilder No Builder for a level-2 menu.

Attributes

In addition to the universal attributes, the following attributes are supported.

Name Type Description
selected boolean Whether the menu item is selected.
Default value: false
selectIcon boolean Whether to display the icon of the menu item being selected.

Events

Name Type Description
onChange (selected: boolean) => void Triggered when the selection status of the menu item is changed manually.
The value true means that the menu item is selected, and false means the opposite.

Example

For details, see Example in Menu.