Menu Item

Menus provide a list of options for the user to choose from.

Menu items provide options for the user to pick from in a menu.

Option 1 Option 2 Option 3 Checkbox Disabled Prefix Icon Suffix Icon

Add content to the start and end of menu items using the prefix and suffix slots.

Treatment Medication 12 Print

Add the disabled attribute to disable the menu item so it cannot be selected.

Option 1 Option 2 Option 3

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.

Autosave Check Spelling Word Wrap

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.

Option 1 Option 2 Option 3 Checkbox 4 Checkbox 5 Checkbox 6

Use menu-item-label and menu-item-sublabel to display a Menu Item with a description.

import '@ods/components/web.menu-item';

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.

Slots

NameDescription
(default)The menu item's label.
prefixUsed to prepend an icon or similar element to the menu item.
suffixUsed to append an icon or similar element to the menu item.
submenuUsed 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/AttributeReflectsTypeDefault
type
'normal' | 'checkbox''normal'
checked
booleanfalse
value
string''
loading
booleanfalse
disabled
booleanfalse
menuItemLabel
menu-item-label
string''
menuItemSubLabel
menu-item-sublabel
string''

Methods

NameDescriptionArguments
getTextLabel()Returns a text label based on the contents of the menu item's default slot.--

Parts

NameDescription
baseThe component's base wrapper.
checked-iconThe checked icon, which is only visible when the menu item is checked.
prefixThe prefix container.
labelThe menu item label.
suffixThe suffix container.
submenu-iconThe submenu icon, visible only when the menu item has a submenu (not yet implemented).

Dependencies

This component automatically imports the following dependencies.

  • ods-icon
  • ods-popup

Search