Set the type attribute to checkbox to create a menu item that will toggle on and off when selected. You can use the checked attribute to set the initial state.
Checkbox menu items are visually indistinguishable from regular menu items. Their ability to be toggled is primarily inferred from context, much like you’d find in the menu of a native app.
The value attribute can be used to assign a hidden value, such as a unique identifier, to a menu item. When an item is selected, the sl-select event will be emitted and a reference to the item will be available at event.detail.item. You can use this reference to access the selected item’s value, its checked state, and more.
Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.
This component is still in development and cannot be imported at this time.
Slots
Name
Description
(default)
The menu item's label.
prefix
Used to prepend an icon or similar element to the menu item.
suffix
Used to append an icon or similar element to the menu item.
submenu
Used to denote a nested menu.
Properties
Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.
Property/Attribute
Reflects
Type
Default
type
'normal' | 'checkbox'
'normal'
checked
boolean
false
value
string
''
loading
boolean
false
disabled
boolean
false
menuItemLabel
menu-item-label
string
''
menuItemSubLabel
menu-item-sublabel
string
''
Methods
Name
Description
Arguments
getTextLabel()
Returns a text label based on the contents of the menu item's default slot.
--
Parts
Name
Description
base
The component's base wrapper.
checked-icon
The checked icon, which is only visible when the menu item is checked.
prefix
The prefix container.
label
The menu item label.
suffix
The suffix container.
submenu-icon
The submenu icon, visible only when the menu item has a submenu (not yet implemented).
Dependencies
This component automatically imports the following dependencies.