Structure
The Menu component consists of several subcomponents:Menu.Root- The root container that manages menu stateMenu.Trigger- The button or element that opens the menuMenu.Content/Menu.List- The container for menu itemsMenu.Item- Individual selectable menu itemsMenu.Divider- Visual separator between menu itemsMenu.Group- Groups related menu itemsMenu.Title- Title for menu groupsMenu.Arrow- Optional arrow pointing to the triggerMenu.Indicator- Visual indicator for the menu state
Import
Usage
Basic Menu
Menu with Groups
Disabled Items
API Reference
Menu.Root
The root container component that manages the menu’s open/closed state.Controls the open state of the menu. Use
bind:open for two-way binding.Optional factory function to create a custom MenuBond instance.
The menu trigger and content components.
Menu.Trigger
The element that triggers the menu to open when clicked.Base component to use for the trigger (e.g., Button).
HTML element type to render.
Additional CSS classes to apply.
Menu.Content / Menu.List
The container that holds the menu items. Appears as a popover when the menu is open.Menu.List is deprecated. Use Menu.Content instead.HTML element type to render.
Base component to customize the content container.
Preset key for styling.
Additional CSS classes to apply.
Callback when the content is mounted.
Callback when the content is destroyed.
Animation configuration.
Enter animation configuration.
Exit animation configuration.
Initial state configuration.
Menu.Item
An individual menu item that can be clicked to perform an action.Click event handler. The menu automatically closes after a click unless
event.preventDefault() is called.Whether the menu item is disabled.
Additional CSS classes to apply.
Preset key for styling.
Callback when the item is mounted.
Callback when the item is destroyed.
Animation configuration.
Enter animation configuration.
Exit animation configuration.
Initial state configuration.
Render prop for children with access to the menu item controller.
Menu.Divider
A visual separator between menu items.Additional CSS classes to apply.
Menu.Group
Groups related menu items together.Additional CSS classes to apply.
The menu items and title to group.
Menu.Title
A title for a group of menu items.Additional CSS classes to apply.
The title content.
Menu.Arrow
An optional arrow that points from the menu to the trigger.Additional CSS classes to apply.
Menu.Indicator
A visual indicator for the menu state.Additional CSS classes to apply.
Features
- Popover-based: Built on top of the Popover component for positioning and behavior
- Keyboard navigation: Support for keyboard navigation through menu items
- Auto-close: Automatically closes when an item is clicked
- Flexible styling: Full control over styling with presets and custom classes
- Animation support: Built-in support for enter/exit animations
- Accessible: Follows accessibility best practices with proper ARIA attributes