Creates a new context menu item.
Configuration options for the menu item.
Configuration options for creating a context menu item.
OptionalbuttonClassName?: stringCustom CSS class name for the menu item's <button> element.
OptionalclassName?: stringCustom CSS class name for the menu item's <li> element.
Optionaldisabled?: booleanWhether the menu item is disabled. Defaults to false.
Optionalend?: ContentContent to display after the label.
The text label to display.
Optionalstart?: ContentContent to display before the label (e.g., an icon element).
Gets whether the menu item is disabled.
true if the menu item is disabled, false otherwise.
Sets whether the menu item is disabled.
true to disable the menu item, false to enable it.
Gets the label text of the menu item.
The current label text.
Sets the label text of the menu item.
The new label text to display.
Gets the start slot content of the menu item.
The start content (string or HTMLElement), or undefined if not set.
Sets the start slot content of the menu item.
A string (rendered as text) or HTMLElement, or undefined to remove.
Removes focus from the menu item, removing the focused styling.
Programmatically triggers a click on the menu item. Only works if the item is not disabled.
This will fire the "click" event with the current context data.
Focuses the menu item, adding the focused styling. Only works if the item is not disabled.
Checks whether there are any registered handlers for the specified event type.
The event type to check.
true if there are registered handlers for the event type, false otherwise.
Removes the menu item from the DOM and cleans up all event listeners and references.
The menu item instance for method chaining.
A context menu item that can be added to a context menu.
Menu items can display a label with optional content before and/or after it, and can be enabled or disabled. When clicked, menu items fire a "click" event with context data including the map, coordinates, and any features at the click location.
Example