sterling-svelte  1.0.12
A modern, accessible, lightweight UI component library for Svelte.
Exciting News! sterling-svelte 2.0 is out and built on Svelte 5! Read all about it here!

Menu

An interactive list of <MenuItem>s

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

<Menu>
  <!-- <MenuItem> ... -->
</Menu>

Members

Property Name Type Default Comment
variant string '' Additional class names to apply

Method Name Parameters Return Type Comment
focusFirstMenuItem Focuses the first menu item.
focusPreviousMenuItem Focuses the previous menu item.
focusNextMenuItem Focuses the next menu item.
focusLastMenuItem Focuses the last menu item.

Considerations

  • Menu is a building block for the other menu components: MenuBar, MenuButton, MenuItem, MenuSeparator.
  • Position is based on the reference element.
  • The menu floats above other elements on the page via portal.
  • Includes HTMLDivElement props, event, and methods

Anatomy

<div class="sterling-menu">
  <div class="menu-items">
    <slot {variant} />
  </div>
</div>