Menu

This component presents a list of options that take immediate action or navigate the user outside of the current context. It can be thought of as a collection of links or buttons.

Anatomy

base anatomy

Props

Menu

The root component that manages the open state and context of the menu.

PropTypeDefaultDescription
openbooleanfalseThe controlled open state of the menu.
defaultOpenbooleanfalseThe default open state when initially rendered. Use when you do not need to control the open state.
onOpenChange(open: boolean) => void-Event handler called when the open state of the menu changes.

Menu.Trigger

The button that toggles the menu. The menu content will position itself against the trigger.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
disabledbooleanfalseWhether the trigger is disabled.

Menu.Content

The component that pops out when the menu is open. Contains all menu items.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
loopbooleanfalseWhen true, keyboard navigation will loop from the last item to the first, and vice versa.
sidetop | right | bottom | left"bottom"The preferred side of the trigger to render the menu against.
sideOffsetnumber0The distance in pixels from the trigger.
alignstart | center | end"start"The preferred alignment against the trigger.
alignOffsetnumber0An offset in pixels from the start or end alignment options.
onInteractOutside(event: Event) => void-Event handler called when an interaction occurs outside the menu.
onCloseAutoFocus(event: Event) => void-Event handler called when focus moves to the trigger after closing.

Menu.Item

An individual selectable item within the menu.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
disabledbooleanfalseWhether the menu item is disabled.
onSelect(event: Event) => void-Event handler called when the user selects an item via mouse or keyboard.
value*string-The unique value of the menu item.

Menu.Group

Used to group multiple related menu items together.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.

Menu.Label

A non-focusable label used to name a group of menu items.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.

Menu.Separator

A visual separator used to divide menu items.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
orientationhorizontal | vertical"horizontal"The orientation of the separator.

Menu.Arrow

An optional arrow element to render alongside the menu. Helps visually link the trigger with the menu content.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
widthnumber10The width of the arrow in pixels.
heightnumber5The height of the arrow in pixels.

Menu.CheckboxItem

A menu item that can be controlled and rendered like a checkbox.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
checkedboolean | indeterminatefalseThe controlled checked state of the checkbox item.
onCheckedChange(checked: boolean | 'indeterminate') => void-Event handler called when the checked state changes.
disabledbooleanfalseWhether the checkbox item is disabled.

Menu.RadioGroup

Used to group multiple radio items together.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
value*string-The value of the selected radio item.
onValueChange(value: string) => void-Event handler called when the selected value changes.

Menu.RadioItem

A menu item that can be controlled and rendered like a radio button within a group.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
value*string-The value of the radio item.
disabledbooleanfalseWhether the radio item is disabled.

Menu.Sub

Contains all the parts of a submenu.

PropTypeDefaultDescription
openbooleanfalseThe controlled open state of the submenu.
defaultOpenbooleanfalseThe default open state when initially rendered.
onOpenChange(open: boolean) => void-Event handler called when the open state of the submenu changes.

Menu.SubTrigger

A menu item that opens a submenu. Must be rendered inside MenuSub.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
disabledbooleanfalseWhether the submenu trigger is disabled.

Menu.SubContent

The component that pops out when a submenu is open. Must be rendered inside MenuSub.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child, merging their props and behavior.
loopbooleanfalseWhen true, keyboard navigation will loop from the last item to the first.
sideOffsetnumber0The distance in pixels from the trigger.
alignOffsetnumber0An offset in pixels from the alignment options.