Menu

Display a list of navigation items or actions in a menu format.

Installation

Import
import { Menu, Button } from '@svelte-atoms/core/menu';

Preset Configuration

Customize the menu appearance using presets

You can customize the default styles for Menu components by defining presets in your configuration:

Examples

Explore different menu variations

Basic Menu

Simple menu with items

Code
<Menu.Root>
  <Menu.Trigger base={Button}>Open Menu</Menu.Trigger>
  <Menu.Content class="max-w-xs rounded-lg border">
    <Menu.Item>New File</Menu.Item>
    <Menu.Item>Open File</Menu.Item>
    <Menu.Item>Save</Menu.Item>
    <Menu.Item>Save As...</Menu.Item>
    <Menu.Item class="text-red-600">Exit</Menu.Item>
  </Menu.Content>
</Menu.Root>

Interactive Menu

Menu with click handlers

Code
<Menu.Root>
  <Menu.Trigger base={Button}>Open Menu</Menu.Trigger>
  <Menu.Content class="max-w-xs rounded-lg border">
    <Menu.Item onclick={() => alert('Profile clicked')}>Profile</Menu.Item>
    <Menu.Item onclick={() => alert('Settings clicked')}>Settings</Menu.Item>
    <Menu.Item onclick={() => alert('Logout clicked')}>Logout</Menu.Item>
  </Menu.Content>
</Menu.Root>

API Reference

Menu.Root Props

Prop
Type
Default
Description
class
string
''
Additional CSS classes

Menu.List Props

Prop
Type
Default
Description
bond
Bond
undefined
Bond object for component communication
base
Component | Snippet
undefined
Base component or snippet to render
preset
PresetModuleName | string
undefined
Preset module name for styling
variants
VariantDefinition | Function
undefined
Variant definition or function to resolve variants
class
ClassValue | ClassValue[]
undefined
CSS class(es) to apply to the element
as
string
undefined
HTML tag to render as
global
boolean
false
Whether to use global styles
initial
NodeFunction
undefined
Function called on initial render
enter
TransitionFunction
undefined
Transition function for entering
exit
TransitionFunction
undefined
Transition function for exiting
animate
NodeFunction
undefined
Animation function
onmount
NodeFunction
undefined
Function called when element is mounted
ondestroy
NodeFunction
undefined
Function called when element is destroyed
children
Snippet
undefined
Children content snippet

Menu.Item Props

Prop
Type
Default
Description
bond
Bond
undefined
Bond object for component communication
base
Component | Snippet
undefined
Base component or snippet to render
preset
PresetModuleName | string
undefined
Preset module name for styling
variants
VariantDefinition | Function
undefined
Variant definition or function to resolve variants
class
ClassValue | ClassValue[]
undefined
CSS class(es) to apply to the element
as
string
undefined
HTML tag to render as
global
boolean
false
Whether to use global styles
initial
NodeFunction
undefined
Function called on initial render
enter
TransitionFunction
undefined
Transition function for entering
exit
TransitionFunction
undefined
Transition function for exiting
animate
NodeFunction
undefined
Animation function
onmount
NodeFunction
undefined
Function called when element is mounted
ondestroy
NodeFunction
undefined
Function called when element is destroyed
children
Snippet
undefined
Children content snippet

Accessibility

Built-in Accessibility Features

  • • Keyboard navigation (Arrow keys)
  • • ARIA menu role
  • • Focus management
  • • Screen reader friendly
  • • Disabled state support