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

MenuButton

A button that opens and closes a menu.

Code
<script lang="ts">
  import { MenuButton } from '@geoffcox/sterling-svelte';
</script>

<MenuButton>
  <!-- button content -->
  {#snippet items()}
    <!-- <MenuItem> ... -->
  {/snippet}
</MenuButton>

Members

Property NameTypeDefaultComment
itemsSnippet | undefinedundefinedThe items to display in the menu.
menuClassstring''Additional class names to apply to the menu.
openbooleanfalseWhen true, the menu is open.
onClose(value: string) => voidCalled when the menu or a descendant menu is closed.
onOpen(value: string) => voidCalled when the menu or a descendant menu is opened.
onSelect(value: string) => voidCalled when a descendant a menu item is selected.
popoverPlacementPopoverPlacementbottom-startThe placement of the menu relative to the button.
valuestringundefinedThe value uniquely identifying this menu button as the root of the menu hierarchy.

Considerations

  • Includes Button props, events, and methods.
  • Includes HTMLButtonElement props, events, and methods.

Anatomy

button (<Button>)
  reference (<div>)
    children (Snippet)
  popover (<Popover>)
    menu (<Menu>)
      items (Snippet)