Skip to main content

MenuItem class

📖 Description

The MenuItem class defines a menu item for the Menu class. A menu item is a selectable item in the menu that executes a function when tapped/clicked. It is derived from the MenuOption class.


🆕 constructor

Creates a new MenuItem instance.

Signature

constructor(label: string, fn?: () => void, disabled?: boolean): MenuItem

Parameters

NameTypeOptionalDescription
labelstringNoSpecifies the item label.
fn() => voidYesSpecifies the command which is invoked when the item is selected.
disabledbooleanYesSpecifies if the item is disabled (default is false).

Return value

Returns a reference to the new MenuItem instance.

▶️ Methods


🔧 badge

Sets a badge for the item.

Signature

badge(badge: string): this

Parameters

NameTypeOptionalDescription
badgestringNoSpecifies the badge.

Return value

Returns a reference to the MenuItem instance to allow chaining.