MenuItem
An actionable item within a <Menu>
Code
<script lang="ts">
import { MenuItem } from '@geoffcox/sterling-svelte';
</script>
<MenuItem text="sterling-svelte" value="menu-item-1">
<!-- <MenuItem> ... -->
</MenuItem>
Members
| Property Name | Type | Default | Comment | | checked | boolean | false |
| disabled | boolean | false |
| role | MenuItemRole | '' |
| text | string | undefined | undefined |
| value | string | '' |
| variant | string | '' |
| Event Name | Data | Comment | | close | { value: string } |
| open | { value: string } |
| select | { value: string } |
Types
| Type Name | Definition | Comment | | MenuItemRole | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' |
Considerations
- MenuItem uses MenuItemContext set by the Menu for some properties and events.
- Includes HTMLButtonElement props, event, and methods
Anatomy
<button class="sterling-menu-item">
<div class="item">
<slot
name="item"
{checked}
{depth}
{disabled}
{hasChildren}
{isMenuBarItem}
{open}
{role}
{text}
{value}
{variant}
>
<MenuItemDisplay>{text}</MenuItemDisplay>
</slot>
</div>
<Popover>
<Menu>
<slot {depth} {disabled} />
</Menu>
</Popover>
</button>