MenuItem
An 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 | null | undefined | false |
| item | Snippet | undefined | undefined |
| menuClass | string | undefined | undefined |
| onClose | (value: string) => void | undefined |
| onOpen | (value: string) => void | undefined |
| onSelect | (value: string) => void | undefined |
| role | MenuItemRole | undefined | 'menuitem' |
| shortcut | string | undefined | undefined |
| text | string | undefined | undefined |
| value | string | |
Types
| Type Name | Definition | Comment |
---|
| MenuItemRole | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' |
Considerations
- Includes HTMLButtonElement props, events, and methods.
Anatomy
<button class="sterling-menu-item">
<div class="item">
{#if item}
{@render item()}
{:else}
<div class="sterling-menu-item-display">
<div class="check"></div>
<div class="content"></div>
<div class="shortcut"></div>
<div class="chevron"></div>
</div>
{/if}
</div>
<Popover>
<Menu>
{@render menu()}
</Menu>
</Popover>
</button>