base-ui-svelte

Menu

A menu of actions or links triggered by a button.

View as Markdown

API Reference

Props mirror Base UI React where applicable, adapted for Svelte 5. Native HTML attributes for the rendered element are also accepted unless noted.

Menu.Root

Extends div HTML attributes.

PropertyTypeDefaultDescription
openboolean | undefinedWhether the component is open (controlled).
defaultOpenbooleanWhether the component is initially open (uncontrolled).
onOpenChange((open: boolean, eventDetails: { reason: OpenChangeReason }) => void) | undefinedEvent handler called when the open state changes.
openOnHoverbooleanOpen the menu when the pointer enters the trigger.
delaynumberOpen delay when `openOnHover` is set (ms).
closeDelaynumberClose delay when leaving trigger/popup under hover (ms).
childrenSnippet<[{ open: boolean }]>Content rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-openPresent when the part is open.

Menu.Arrow

Extends span HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-openPresent when the part is open.

Menu.Backdrop

Extends div HTML attributes.

PropertyTypeDefaultDescription
renderstringHTML element tag to render instead of the default host element.
dismissibleboolean
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-openPresent when the part is open.

Menu.CheckboxItem

Extends div HTML attributes.

PropertyTypeDefaultDescription
checkedboolean | undefinedControlled checked state.
defaultCheckedbooleanUncontrolled initial checked state.
onCheckedChange((checked: boolean, event: Event) => void) | undefinedEvent handler called when the checked state changes.
disabledbooleanfalseWhether the control ignores user interaction.
childrenSnippet<[{ checked: boolean }]>Content rendered inside the part.
Data attributeDescription
data-checkedPresent when the part is checked.
data-disabledPresent when the part is disabled.
data-highlightedPresent when the item is highlighted.
data-uncheckedPresent when the part is unchecked.

Menu.CheckboxItemIndicator

Extends span HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-checkedPresent when the part is checked.
data-disabledPresent when the part is disabled.
data-uncheckedPresent when the part is unchecked.

Menu.Group

Extends div HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.

Menu.GroupLabel

Extends div HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.

Menu.Item

Extends div HTML attributes.

PropertyTypeDefaultDescription
disabledbooleanfalseWhether the control ignores user interaction.
onClick((event: MouseEvent) => void) | undefined
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-disabledPresent when the part is disabled.
data-highlightedPresent when the item is highlighted.

Menu.LinkItem

Extends anchor HTML attributes.

PropertyTypeDefaultDescription
disabledbooleanfalseWhether the control ignores user interaction.
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-disabledPresent when the part is disabled.
data-highlightedPresent when the item is highlighted.

Menu.Popup

Extends div HTML attributes.

PropertyTypeDefaultDescription
renderstringHTML element tag to render instead of the default host element.
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-ending-stylePresent while the exit animation can run.
data-openPresent when the part is open.
data-starting-stylePresent while the enter animation can run.

Menu.Portal

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.

Menu.Positioner

Extends div HTML attributes.

PropertyTypeDefaultDescription
sideSide
alignAlign
sideOffsetnumber
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-openPresent when the part is open.

Menu.RadioGroup

Extends div HTML attributes.

PropertyTypeDefaultDescription
valuestring | undefinedControlled value.
defaultValuestringUncontrolled initial value.
onValueChange((value: string, event: Event) => void) | undefinedEvent handler called when the value changes.
disabledbooleanfalseWhether the control ignores user interaction.
childrenSnippet<[{ value: string }]>Content rendered inside the part.
Data attributeDescription
data-disabledPresent when the part is disabled.

Menu.RadioItem

Extends div HTML attributes.

PropertyTypeDefaultDescription
valuestringControlled value.
disabledbooleanfalseWhether the control ignores user interaction.
childrenSnippet<[{ checked: boolean }]>Content rendered inside the part.
Data attributeDescription
data-checkedPresent when the part is checked.
data-disabledPresent when the part is disabled.
data-highlightedPresent when the item is highlighted.
data-uncheckedPresent when the part is unchecked.

Menu.RadioItemIndicator

Extends span HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-checkedPresent when the part is checked.
data-disabledPresent when the part is disabled.
data-uncheckedPresent when the part is unchecked.

Menu.Separator

Extends div HTML attributes.

No component-specific props — HTML attributes and children only.

Menu.SubmenuRoot

Extends div HTML attributes.

PropertyTypeDefaultDescription
openboolean | undefinedWhether the component is open (controlled).
defaultOpenbooleanWhether the component is initially open (uncontrolled).
onOpenChange((open: boolean, eventDetails: { reason: OpenChangeReason }) => void) | undefinedEvent handler called when the open state changes.
childrenSnippet<[{ open: boolean }]>Content rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-openPresent when the part is open.

Menu.SubmenuTrigger

Extends div HTML attributes.

PropertyTypeDefaultDescription
disabledbooleanfalseWhether the control ignores user interaction.
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-disabledPresent when the part is disabled.
data-highlightedPresent when the item is highlighted.
data-openPresent when the part is open.

Menu.Trigger

Extends button HTML attributes.

PropertyTypeDefaultDescription
renderstringHTML element tag to render instead of the default host element.
disabledbooleanfalseWhether the control ignores user interaction.
openOnHoverboolean
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-closedPresent when the part is closed.
data-disabledPresent when the part is disabled.
data-openPresent when the part is open.

Menu.Viewport

Extends div HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.