Skip to content

ContextMenuItem

Menu item component.

Props

PropertyDescriptionTypeDefault
labelThe label of menu.string
iconThe icon for menu item.string
iconFontClassCustom icon library font class name.stringiconfont
preserveIconWidthShould a fixed-width icon area be reserved for menu items without icon.booleantrue
svgIconDisplay icons use svg symbol (<use xlink:href="...">) , only valid when icon attribute is empty.string
svgPropsThe user-defined attribute of the svg tag, which is valid when using svgIcon.SVGAttributes
disabledDisable menu item?booleanfalse
checkedIs this menu item checked?booleanfalse
shortcutShortcut key text display on the right. The shortcut keys here are only for display. You need to handle the key events by yourself.string''
clickableWhenHasChildrenWhen there are subitems in this item, is it allowed to trigger its own click event?booleanfalse
clickCloseShould close menu when Click this menu item ?booleantrue
customClassCustom submenu class.string
onClickMenu item click event handler.Function()

Slots

Slot nameDescriptionArguments
defaultRendering slot for the current menu-
iconIcon rendering slot-
labelLabel rendering slot-
shortcutCheck mark render slotMenuItemRenderData
checkShortcut key badge render slotMenuItemRenderData
rightArrowRight Arrow rendering slot-

Click

Event nameDescriptionArguments
clickThis event is triggered when the click this menu item-
subMenuOpenTrigger this event when a submenu is opened-
subMenuCloseTrigger this event when the submenu is closed-

Control instance of a menu item.

getSubMenuInstance(): ContextSubMenuInstance|undefined

Get current showing submenu instance.

Returns

Explan
Return ContextSubMenuInstance of current submenu, return undefined if menu is not showing.

getElement(): HTMLElement

Get html Element of this item.

showSubMenu(): void

Show submenu of this item.

hideSubMenu(): void

Force hide submenu of this item.

isDisabledOrHidden(): boolean

Check is this item disabled or hidden.

Released under the MIT License.