sterling-svelte  2.0.0
A modern, accessible, lightweight UI component library for Svelte.

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 NameTypeDefaultComment
checkedboolean | null | undefinedfalseWhen true, the menu item is checked. Displayed only when role is set to menuitemcheckbox or menuitemradio.
itemSnippet | undefinedundefinedWhen undefined, a default item is rendered with a chevron, checkmark, text, and shortcut.
menuClassstring | undefinedundefinedA class applied to any child menu.
onClose(value: string) => voidundefinedCalled when the menu item is closed.
onOpen(value: string) => voidundefinedCalled when the menu item is opened.
onSelect(value: string) => voidundefinedCalled when the menu item is selected.
roleMenuItemRole | undefined'menuitem'The role of the menu item. Allows regular, checkbox, or radio menu items.
shortcutstring | undefinedundefinedThe shortcut key sequence associated with the menu item. Not used if item is set.
textstring | undefinedundefinedThe text of the menu item. Not used if item is set.
valuestringUniquely identifies the menu item within the menu hierarchy.

Types

Type NameDefinitionComment
MenuItemRole'menuitem' | 'menuitemcheckbox' | 'menuitemradio'

Considerations

  • Includes HTMLButtonElement props, events, and methods.

Anatomy

menu item (<button>)
  item (<div>)
    item (Snippet)
      container (<div>)
        checkmark (<div>)
        content (<div>)
        shortcut (<div>)
        chevron (<div>)
  popover (<Popover>)
    menu (<Menu>)
      children (Snippet)