Menu
A list of actions opened from a trigger
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "@nyte-ai/ui/menu";A list of actions that opens from a button. Every row reserves a leading icon column and a trailing meta column, even when empty. The list opens below its trigger. For a control whose label shows the current choice, use Select, which opens over its trigger.
Usage
MenuItemandMenuRadioItemclose on click.MenuCheckboxItemandMenuSwitchItemstay open.closeOnClickchanges either.- For a searchable palette under a scrim, use Command.
Anatomy
<Menu>
<MenuTrigger />
<MenuContent>
<MenuGroup>
<MenuGroupLabel />
<MenuItem />
<MenuLinkItem />
<MenuCheckboxItem />
<MenuSwitchItem />
</MenuGroup>
<MenuSeparator />
<MenuRadioGroup>
<MenuRadioItem value="choice" />
</MenuRadioGroup>
<MenuSub>
<MenuSubTrigger />
<MenuSubContent>
<MenuItem />
</MenuSubContent>
</MenuSub>
</MenuContent>
</Menu>Examples
import { Button } from "@nyte-ai/ui/button";
import {
Menu,
MenuContent,
MenuGroup,
MenuGroupLabel,
MenuItem,
MenuRadioGroup,
MenuRadioItem,
MenuSeparator,
MenuSub,
MenuSubContent,
MenuSubTrigger,
MenuSwitchItem,
MenuTrigger,
} from "@nyte-ai/ui/menu";
import { useState } from "react";
function SessionMenu() {
const [effort, setEffort] = useState("medium");
const [pinned, setPinned] = useState(false);
return (
<Menu>
<MenuTrigger render={<Button variant="outline">Session</Button>} />
<MenuContent>
<MenuGroup>
<MenuGroupLabel>Session</MenuGroupLabel>
<MenuItem icon="pencil" meta="โR" onClick={() => {}}>
Rename
</MenuItem>
<MenuItem icon="copy" onClick={() => {}}>
Duplicate
</MenuItem>
<MenuItem icon="archive" disabled>
Archive
</MenuItem>
<MenuSwitchItem icon="pin" checked={pinned} onCheckedChange={setPinned}>
Pinned
</MenuSwitchItem>
</MenuGroup>
<MenuSeparator />
<MenuSub>
<MenuSubTrigger icon="bolt" value={effort}>
Effort
</MenuSubTrigger>
<MenuSubContent>
<MenuRadioGroup value={effort} onValueChange={setEffort}>
<MenuRadioItem value="low">low</MenuRadioItem>
<MenuRadioItem value="medium">medium</MenuRadioItem>
<MenuRadioItem value="high">high</MenuRadioItem>
</MenuRadioGroup>
</MenuSubContent>
</MenuSub>
<MenuSeparator />
<MenuItem icon="trash" variant="danger" onClick={() => {}}>
Delete
</MenuItem>
</MenuContent>
</Menu>
);
}Props
Every styled part takes xstyle, className, and style. See
Theming. Menu, MenuTrigger, MenuGroup, MenuRadioGroup, and
MenuSub are Base UI's.
The reference tables below come from Base UI, MIT, ยฉ Material-UI SAS.
Menu
Groups all parts of the menu. Doesn't render its own HTML element.
Root Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultOpen | boolean | false | Whether the menu is initially open. To render a controlled menu, use the open prop instead. |
| open | boolean | - | Whether the menu is currently open. |
| onOpenChange | ((open: boolean, eventDetails: Menu.Root.ChangeEventDetails) => void) | - | Event handler called when the menu is opened or closed. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them.
Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state. |
| actionsRef | React.RefObject<Menu.Root.Actions | null> | - | A ref to imperative actions. unmount: Manually unmounts the menu.
Call this after any externally controlled closing animation finishes.close: When specified, the menu can be closed imperatively. |
| closeParentOnEsc | boolean | false | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
| defaultTriggerId | string | null | - | ID of the trigger that the menu is associated with.
This is useful in conjunction with the defaultOpen prop to create an initially open menu. |
| handle | Menu.Handle<Payload> | - | A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state. |
| loopFocus | boolean | true | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
| modal | boolean | true | Determines if the menu enters a modal state when open. true: user interaction is limited to the menu: document page scroll is locked and pointer interactions on outside elements are disabled.false: user interaction with the rest of the document is allowed. On touch devices, a true modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior. Nested menus ignore this prop, and menus opened by hover are never modal. |
| onOpenChangeComplete | ((open: boolean) => void) | - | Event handler called after any animations complete when the menu is opened or closed. |
| triggerId | string | null | - | ID of the trigger that the menu is associated with.
This is useful in conjunction with the open prop to create a controlled menu.
There's no need to specify this prop when the menu is uncontrolled (that is, when the open prop is not set). |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| orientation | Menu.Root.Orientation | 'vertical' | The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys. |
| children | React.ReactNode | PayloadChildRenderFunction<Payload> | - | The content of the menu.
This can be a regular React node or a render function that receives the payload of the active trigger. |
MenuTrigger
A button that opens the menu.
Renders a <button> element.
Trigger Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| handle | Menu.Handle<Payload> | - | A handle to associate the trigger with a menu. |
| nativeButton | boolean | true | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>). |
| payload | Payload | - | A payload to pass to the menu when it is opened. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| openOnHover | boolean | - | Whether the menu should also open when the trigger is hovered. |
| delay | number | 100 | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the openOnHover prop. |
| closeDelay | number | 0 | How long to wait before closing the menu that was opened on hover.
Specified in milliseconds. Requires the openOnHover prop. |
| children | React.ReactNode | - | - |
| className | string | ((state: Menu.Trigger.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.Trigger.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.Trigger.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
Trigger Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-popup-open | - | Present when the corresponding menu is open. |
| data-pressed | - | Present when the trigger is pressed. |
| data-disabled | - | Present when the trigger is disabled. |
MenuContent
Renders the portal, positioner, and popup. Positioning props go to the positioner and the rest,
including ref, to the popup.
| Prop | Type | Default |
|---|---|---|
side | "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" | "bottom" |
align | "start" | "center" | "end" | "start" |
sideOffset | number | OffsetFunction | 4 |
alignOffset | number | OffsetFunction | |
anchor | Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null | the trigger |
collisionAvoidance | CollisionAvoidance | { side: "flip", align: "shift", fallbackAxisSide: "none" } |
collisionPadding | number | Padding | 8 |
tint | Tint | |
matchAnchorWidth | boolean | false |
The popup scrolls when it runs out of room.
Positioner
Positions the menu popup against the trigger.
Renders a <div> element.
Positioner Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| disableAnchorTracking | boolean | false | Whether to disable the popup from tracking any layout shift of its positioning anchor. |
| align | Align | 'center' | How to align the popup relative to the specified side. Submenus and menubars default to 'start'. |
| alignOffset | number | OffsetFunction | 0 | Additional offset along the alignment axis in pixels.
Also accepts a function that returns the offset to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side. |
| side | Side | 'bottom' | Which side of the anchor element to align the popup against.
May automatically change to avoid collisions. Submenus and vertical menubars default to 'inline-end'. |
| sideOffset | number | OffsetFunction | 0 | Distance between the anchor and the popup in pixels.
Also accepts a function that returns the distance to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side. |
| arrowPadding | number | 5 | Minimum distance to maintain between the arrow and the edges of the popup. Use it to prevent the arrow element from hanging out of the rounded corners of a popup. |
| anchor | Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null) | null | - | An element to position the popup against. By default, the popup will be positioned against the trigger. |
| collisionAvoidance | CollisionAvoidance | - | Determines how to handle collisions when positioning the popup. side controls overflow on the preferred placement axis (top/bottom or left/right): 'flip': keep the requested side when it fits; otherwise try the opposite side
(top and bottom, or left and right).'shift': never change side; keep the requested side and move the popup within
the clipping boundary so it stays visible.'none': do not correct side-axis overflow. align controls overflow on the alignment axis (start/center/end): 'flip': keep side, but swap start and end when the requested alignment overflows.'shift': keep side and requested alignment, then nudge the popup along the
alignment axis to fit.'none': do not correct alignment-axis overflow. fallbackAxisSide controls fallback behavior on the perpendicular axis when the
preferred axis cannot fit: 'start': allow perpendicular fallback and try the logical start side first
(top before bottom, or left before right in LTR).'end': allow perpendicular fallback and try the logical end side first
(bottom before top, or right before left in LTR).'none': do not fallback to the perpendicular axis. When side is 'shift', explicitly setting align only supports 'shift' or 'none'.
If align is omitted, it defaults to 'flip'. |
| collisionBoundary | Boundary | 'clipping-ancestors' | An element or a rectangle that delimits the area that the popup is confined to. |
| collisionPadding | Padding | 5 | Additional space to maintain from the edge of the collision boundary. |
| sticky | boolean | false | Whether to maintain the popup in the viewport after the anchor element was scrolled out of view. |
| positionMethod | 'absolute' | 'fixed' | 'absolute' | Determines which CSS position property to use. |
| className | string | ((state: Menu.Positioner.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.Positioner.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.Positioner.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
alignOffset Prop Example:
<Positioner
alignOffset={({ side, align, anchor, positioner }) => {
return side === 'top' || side === 'bottom' ? anchor.width : anchor.height;
}}
/>sideOffset Prop Example:
<Positioner
sideOffset={({ side, align, anchor, positioner }) => {
return side === 'top' || side === 'bottom' ? anchor.height : anchor.width;
}}
/>collisionAvoidance Prop Example:
<Positioner
collisionAvoidance={{
side: 'shift',
align: 'shift',
fallbackAxisSide: 'none',
}}
/>Positioner Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-open | - | Present when the menu popup is open. |
| data-closed | - | Present when the menu popup is closed. |
| data-anchor-hidden | - | Present when the anchor is hidden. |
| data-align | 'start' | 'center' | 'end' | Indicates how the popup is aligned relative to the specified side. |
| data-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | Indicates which side the popup is positioned relative to the anchor. |
Positioner CSS Variables:
| Variable | Type | Description |
|---|---|---|
--anchor-height | number | The anchor's height. |
--anchor-width | number | The anchor's width. |
--available-height | number | The available height between the anchor and the edge of the viewport. |
--available-width | number | The available width between the anchor and the edge of the viewport. |
--positioner-height | number | The height of the menu's positioner.
It is important to set height to this value when using CSS to animate size changes. |
--positioner-width | number | The width of the menu's positioner.
It is important to set width to this value when using CSS to animate size changes. |
--transform-origin | string | The coordinates that this element is anchored to. Used for animations and transitions. |
Popup
A container for the menu items.
Renders a <div> element.
Popup Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null) | - | Determines the element to focus when the menu is closed. false: Do not move focus.true: Move focus based on the default behavior (trigger or previously focused element).RefObject: Move focus to the ref element.function: Called with the interaction type (mouse, touch, pen, or keyboard).
Return an element to focus, true to use the default behavior, or false/undefined to do nothing. |
| children | React.ReactNode | - | - |
| className | string | ((state: Menu.Popup.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.Popup.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.Popup.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
Popup Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-open | - | Present when the menu is open. |
| data-closed | - | Present when the menu is closed. |
| data-align | 'start' | 'center' | 'end' | Indicates how the popup is aligned relative to specified side. |
| data-instant | 'click' | 'dismiss' | 'group' | 'trigger-change' | Present if animations should be instant. |
| data-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | Indicates which side the popup is positioned relative to the anchor. |
| data-starting-style | - | Present when the menu begins animating in. |
| data-ending-style | - | Present when the menu is animating out. |
MenuSubContent
Takes the same props as MenuContent except matchAnchorWidth. side, align, and
collisionAvoidance have no defaults of their own. Base UI opens a submenu at inline-end,
aligned to start.
| Prop | Default |
|---|---|
sideOffset | 6 |
alignOffset | 0 when centered, otherwise -4 |
MenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
icon | IconName | ||
leading | ReactNode | Overrides icon. | |
meta | ReactNode | Display only. It binds no key. | |
variant | "default" | "danger" | "default" | |
layout | "menu" | "plain" | "menu" | plain removes the leading column. |
children | ReactNode | Optional when render supplies the content. |
An individual interactive item in the menu.
Renders a <div> element.
Item Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | - | Overrides the text label to use when the item is matched during keyboard text navigation. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | - | The click handler for the menu item. |
| closeOnClick | boolean | true | Whether to close the menu when the item is clicked. |
| nativeButton | boolean | false | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| className | string | ((state: Menu.Item.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.Item.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.Item.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
Item Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-highlighted | - | Present when the menu item is highlighted. |
| data-disabled | - | Present when the menu item is disabled. |
MenuLinkItem
Renders a link. Takes the props in the MenuItem table except variant.
A link in the menu that can be used to navigate to a different page or section.
Renders an <a> element.
LinkItem Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | - | Overrides the text label to use when the item is matched during keyboard text navigation. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| className | string | ((state: Menu.LinkItem.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.LinkItem.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, state: Menu.LinkItem.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
LinkItem Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-highlighted | - | Present when the link is highlighted. |
MenuCheckboxItem
Takes the props in the MenuItem table except variant. A checkmark follows meta
while checked.
A menu item that toggles a setting on or off.
Renders a <div> element.
CheckboxItem Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | - | Overrides the text label to use when the item is matched during keyboard text navigation. |
| defaultChecked | boolean | false | Whether the checkbox item is initially ticked. To render a controlled checkbox item, use the checked prop instead. |
| checked | boolean | - | Whether the checkbox item is currently ticked. To render an uncontrolled checkbox item, use the defaultChecked prop instead. |
| onCheckedChange | ((checked: boolean, eventDetails: Menu.CheckboxItem.ChangeEventDetails) => void) | - | Event handler called when the checkbox item is ticked or unticked. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | - | The click handler for the menu item. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| nativeButton | boolean | false | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| className | string | ((state: Menu.CheckboxItem.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.CheckboxItem.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.CheckboxItem.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
CheckboxItem Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-checked | - | Present when the menu checkbox item is checked. |
| data-unchecked | - | Present when the menu checkbox item is not checked. |
| data-highlighted | - | Present when the menu checkbox item is highlighted. |
| data-disabled | - | Present when the menu checkbox item is disabled. |
MenuSwitchItem
A MenuCheckboxItem that draws a switch in place of meta and the checkmark. It takes no meta.
MenuRadioGroup
Groups related radio items.
Renders a <div> element.
RadioGroup Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultValue | any | - | The uncontrolled value of the radio item that should be initially selected. To render a controlled radio group, use the value prop instead. |
| value | any | - | The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the defaultValue prop instead. |
| onValueChange | ((value: any, eventDetails: Menu.RadioGroup.ChangeEventDetails) => void) | - | Function called when the selected value changes. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| children | React.ReactNode | - | The content of the component. |
| className | string | ((state: Menu.RadioGroup.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.RadioGroup.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.RadioGroup.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
MenuRadioItem
Takes the props in the MenuItem table except variant. A checkmark follows meta
on the chosen row.
| Prop | Type | Default | Description |
|---|---|---|---|
closeOnClick | boolean | true | Replaces Base UI's false below. |
A menu item that works like a radio button in a given group.
Renders a <div> element.
RadioItem Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | - | Overrides the text label to use when the item is matched during keyboard text navigation. |
| value* | any | - | Value of the radio item. This is the value that will be set in the Menu.RadioGroup when the item is selected. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | - | The click handler for the menu item. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| nativeButton | boolean | false | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| className | string | ((state: Menu.RadioItem.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.RadioItem.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.RadioItem.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
RadioItem Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-checked | - | Present when the menu radio item is selected. |
| data-unchecked | - | Present when the menu radio item is not selected. |
| data-highlighted | - | Present when the menu radio item is highlighted. |
| data-disabled | - | Present when the menu radio item is disabled. |
MenuGroup
Groups related menu items with the corresponding label.
Renders a <div> element.
Group Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | The content of the component. |
| className | string | ((state: Menu.Group.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.Group.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.Group.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
MenuGroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div> element.
GroupLabel Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: Menu.GroupLabel.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.GroupLabel.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.GroupLabel.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
MenuSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
inset | boolean | false | Shortens the line. |
A separator element accessible to screen readers.
Renders a <div> element.
Separator Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | Orientation | 'horizontal' | The orientation of the separator. |
| className | string | ((state: SeparatorState) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: SeparatorState) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: SeparatorState) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
MenuSub
Groups all parts of a submenu. Doesn't render its own HTML element.
SubmenuRoot Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultOpen | boolean | false | Whether the menu is initially open. To render a controlled menu, use the open prop instead. |
| open | boolean | - | Whether the menu is currently open. |
| onOpenChange | ((open: boolean, eventDetails: Menu.SubmenuRoot.ChangeEventDetails) => void) | - | Event handler called when the menu is opened or closed. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them.
Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state. |
| actionsRef | React.RefObject<Menu.Root.Actions | null> | - | A ref to imperative actions. unmount: Manually unmounts the menu.
Call this after any externally controlled closing animation finishes.close: When specified, the menu can be closed imperatively. |
| closeParentOnEsc | boolean | false | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
| loopFocus | boolean | true | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
| onOpenChangeComplete | ((open: boolean) => void) | - | Event handler called after any animations complete when the menu is opened or closed. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| orientation | Menu.Root.Orientation | 'vertical' | The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys. |
| children | React.ReactNode | - | The content of the submenu. |
MenuSubTrigger
Takes icon, leading, and layout as MenuItem does.
| Prop | Type | Description |
|---|---|---|
value | ReactNode | Current choice before the chevron. |
A menu item that opens a submenu.
Renders a <div> element.
SubmenuTrigger Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | - | Overrides the text label to use when the item is matched during keyboard text navigation. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | - | - |
| nativeButton | boolean | false | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| openOnHover | boolean | true | Whether the menu should also open when the trigger is hovered. |
| delay | number | 100 | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the openOnHover prop. |
| closeDelay | number | 0 | How long to wait before closing the menu that was opened on hover.
Specified in milliseconds. Requires the openOnHover prop. |
| className | string | ((state: Menu.SubmenuTrigger.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Menu.SubmenuTrigger.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Menu.SubmenuTrigger.State) => ReactElement) | - | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
SubmenuTrigger Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-popup-open | - | Present when the corresponding submenu is open. |
| data-highlighted | - | Present when the submenu trigger is highlighted. |
| data-disabled | - | Present when the submenu trigger is disabled. |
Accessibility
- The popup has
role="menu". Give itaria-labelwhen the trigger's text does not name it. - Items are
menuitem, radio items aremenuitemradio, and checkbox and switch items aremenuitemcheckboxwitharia-checked. - Arrow Down and Up move focus and wrap. Home and End jump. Typing matches item text, or
labelwhen set. Enter and Space activate. Escape closes and returns focus to the trigger. - Arrow Right opens a submenu. Arrow Left closes it.
- Disabled items stay reachable with the arrow keys and do not activate.
- Icons, switches, and checkmarks are hidden from assistive technology, so the label must say what the row does.