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
Name | Type | Optional | Description |
---|---|---|---|
label | string | No | Specifies the item label. |
fn | () => void | Yes | Specifies the command which is invoked when the item is selected. |
disabled | boolean | Yes | Specifies 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
Name | Type | Optional | Description |
---|---|---|---|
badge | string | No | Specifies the badge. |
Return value
Returns a reference to the MenuItem
instance to allow chaining.