--- meta: title: Menu Item description: Menu items provide options for the user to pick from in a menu. layout: component --- ```html:preview Option 1 Option 2 Option 3 Checkbox Disabled Prefix Icon Suffix Icon ``` {% raw %} ```jsx:react import SlDivider from '@shoelace-style/shoelace/dist/react/divider'; import SlIcon from '@shoelace-style/shoelace/dist/react/icon'; import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => ( Option 1 Option 2 Option 3 Checkbox Disabled Prefix Icon Suffix Icon ); ``` {% endraw %} ## Examples ### Disabled Add the `disabled` attribute to disable the menu item so it cannot be selected. ```html:preview Option 1 Option 2 Option 3 ``` {% raw %} ```jsx:react import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => ( Option 1 Option 2 Option 3 ); ``` {% endraw %} ### Prefix & Suffix Add content to the start and end of menu items using the `prefix` and `suffix` slots. ```html:preview Home Messages 12 Settings ``` {% raw %} ```jsx:react import SlBadge from '@shoelace-style/shoelace/dist/react/badge'; import SlDivider from '@shoelace-style/shoelace/dist/react/divider'; import SlIcon from '@shoelace-style/shoelace/dist/react/icon'; import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => ( Home Messages 12 Settings ); ``` {% endraw %} ### Checkbox Menu Items 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. ```html:preview Autosave Check Spelling Word Wrap ``` {% raw %} ```jsx:react import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => ( Autosave Check Spelling Word Wrap ); ``` {% endraw %} ### Value & Selection 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. ```html:preview Option 1 Option 2 Option 3 Checkbox 4 Checkbox 5 Checkbox 6 ``` {% raw %} ```jsx:react import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => { function handleSelect(event) { const item = event.detail.item; // Toggle checked state item.checked = !item.checked; // Log value console.log(`Selected value: ${item.value}`); } return ( Option 1 Option 2 Option 3 ); }; ``` {% endraw %}