Menu
A list of actions in a dropdown, enhanced with keyboard navigation.
View as MarkdownAnatomy
Import the component and assemble its parts:
import { Menu } from '@base-ui/react/menu';
<Menu.Root>
<Menu.Trigger />
<Menu.Portal>
<Menu.Backdrop />
<Menu.Positioner>
<Menu.Popup>
<Menu.Arrow />
<Menu.Item />
<Menu.LinkItem />
<Menu.Separator />
<Menu.Group>
<Menu.GroupLabel />
</Menu.Group>
<Menu.RadioGroup>
<Menu.RadioItem />
</Menu.RadioGroup>
<Menu.CheckboxItem />
<Menu.SubmenuRoot>
<Menu.SubmenuTrigger />
</Menu.SubmenuRoot>
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
</Menu.Root>Examples
Open on hover
To create a menu that opens on hover, add the openOnHover prop to <Menu.Trigger>. You can additionally configure how quickly the menu opens on hover using the delay prop.
Checkbox items
Use the <Menu.CheckboxItem> part to create a menu item that can toggle a setting on or off.
Radio items
Use the <Menu.RadioGroup> and <Menu.RadioItem> parts to create menu items that work like radio buttons.
Close on click
Use the closeOnClick prop to change whether the menu closes when an item is clicked.
// Close the menu when a checkbox item is clicked
<Menu.CheckboxItem closeOnClick />
// Keep the menu open when an item is clicked
<Menu.Item closeOnClick={false} />Group labels
Use the <Menu.GroupLabel> part to add a label to a <Menu.Group>
Nested menu
To create a submenu, nest another menu inside the parent menu with <Menu.SubmenuRoot>. Use the <Menu.SubmenuTrigger> part for the menu item that opens the nested menu.
<Menu.Root>
<Menu.Trigger />
<Menu.Portal>
<Menu.Positioner>
<Menu.Popup>
<Menu.Arrow />
<Menu.Item />
{/* Submenu */}
<Menu.SubmenuRoot>
<Menu.SubmenuTrigger />
<Menu.Portal>
<Menu.Positioner>
<Menu.Popup>
{/* Submenu items */}
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
</Menu.SubmenuRoot>
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
</Menu.Root>Navigate to another page
Use the <Menu.LinkItem> part to create a link.
<Menu.LinkItem href="/projects">Go to Projects</<Menu.LinkItem>Open a dialog
In order to open a dialog using a menu, control the dialog state and open it imperatively using the onClick handler on the menu item.
import * as React from 'react';
import { Dialog } from '@base-ui/react/dialog';
import { Menu } from '@base-ui/react/menu';
function ExampleMenu() {
const [dialogOpen, setDialogOpen] = React.useState(false);
return (
<React.Fragment>
<Menu.Root>
<Menu.Trigger>Open menu</Menu.Trigger>
<Menu.Portal>
<Menu.Positioner>
<Menu.Popup>
{/* Open the dialog when the menu item is clicked */}
<Menu.Item onClick={() => setDialogOpen(true)}>Open dialog</Menu.Item>
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
</Menu.Root>
{/* Control the dialog state */}
<Dialog.Root open={dialogOpen} onOpenChange={setDialogOpen}>
<Dialog.Portal>
<Dialog.Backdrop />
<Dialog.Popup>
{/* Rest of the dialog */}
</Dialog.Popup>
</Dialog.Portal>
</Dialog.Root>
</React.Fragment>
);
}Detached triggers
A menu can be opened by a trigger that lives either inside or outside the <Menu.Root>.
Keep the trigger inside <Menu.Root> for simple, tightly coupled layouts like the hero demo at the top of this page.
When the trigger and menu content need to live in different parts of the tree (for example, in a card list that controls a menu rendered near the document root), create a handle with Menu.createHandle() and pass it to both the trigger and the root.
Note that only top-level menus can have detached triggers.
Submenus must have their triggers defined within the SubmenuRoot part.
const demoMenu = Menu.createHandle();
<Menu.Trigger handle={demoMenu}>
Actions
</Menu.Trigger>
<Menu.Root handle={demoMenu}>
<Menu.Portal>
<Menu.Positioner>
<Menu.Popup>
<Menu.Item>Edit</Menu.Item>
<Menu.Item>Share</Menu.Item>
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
</Menu.Root>Multiple triggers
One menu can be opened by several triggers.
You can either render multiple <Menu.Trigger> components inside the same <Menu.Root>, or attach several detached triggers to the same handle.
<Menu.Root>
<Menu.Trigger>Row actions</Menu.Trigger>
<Menu.Trigger>Quick actions</Menu.Trigger>
{/* Rest of the menu */}
</Menu.Root>const projectMenu = Menu.createHandle();
<Menu.Trigger handle={projectMenu}>Row actions</Menu.Trigger>
<Menu.Trigger handle={projectMenu}>Quick actions</Menu.Trigger>
<Menu.Root handle={projectMenu}>
{/* Rest of the menu */}
</Menu.Root>Menus can render different content depending on which trigger opened them.
Pass a payload prop to each <Menu.Trigger> and read it via a function child on <Menu.Root>.
Provide a type argument to createHandle() to strongly type the payload.
const menus = {
file: ['New', 'Open', 'Save'],
edit: ['Undo', 'Redo', 'Cut', 'Copy', 'Paste'],
}
const demoMenu = Menu.createHandle<{ items: string[] }>();
<Menu.Trigger handle={demoMenu} payload={{ items: menus.file }}>
File
</Menu.Trigger>
<Menu.Trigger handle={demoMenu} payload={{ items: menus.edit }}>
Edit
</Menu.Trigger>
<Menu.Root handle={demoMenu}>
{({ payload }) => (
<Menu.Portal>
<Menu.Positioner>
<Menu.Popup>
{(payload?.items ?? []).map((item) => (
<Menu.Item key={item}>{item}</Menu.Item>
))}
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
)}
</Menu.Root>Controlled mode with multiple triggers
Control a menu’s open state externally with the open and onOpenChange props on <Menu.Root>.
When more than one trigger can open the menu, track the active trigger with the triggerId prop on <Menu.Root> and matching id props on each <Menu.Trigger>.
The onOpenChange callback receives eventDetails, which includes the DOM element that initiated the change, so you can update your triggerId state when the user activates a different trigger.
API reference
Root
Groups all parts of the menu. Doesn’t render its own HTML element.
defaultOpenbooleanfalse
boolean- Name
- Description
Whether the menu is initially open.
To render a controlled menu, use the
openprop instead.- Type
boolean | undefined- Default
false
openboolean—
boolean- Name
- Description
Whether the menu is currently open.
- Type
boolean | undefined
onOpenChangefunction—
function- Name
- Description
Event handler called when the menu is opened or closed.
- Type
| (( open: boolean, eventDetails: Menu.Root.ChangeEventDetails, ) => void) | undefined
highlightItemOnHoverbooleantrue
boolean- Description
Whether moving the pointer over items should highlight them. Disabling this prop allows CSS
:hoverto be differentiated from the:focus(data-highlighted) state.- Type
boolean | undefined- Default
true
actionsRef| React.RefObject<Menu.Root.Actions
| null>—
| React.RefObject<Menu.Root.Actions
| null>- Name
- Description
A ref to imperative actions.
unmount: When specified, the menu will not be unmounted when closed. Instead, theunmountfunction must be called to unmount the menu manually. Useful when the menu’s animation is controlled by an external library.close: When specified, the menu can be closed imperatively.
- Type
React.RefObject<Menu.Root.Actions | null> | undefined
closeParentOnEscbooleanfalse
boolean- Name
- Description
When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
- Type
boolean | undefined- Default
false
defaultTriggerIdstring | null—
string | null- Name
- Description
ID of the trigger that the popover is associated with. This is useful in conjunction with the
defaultOpenprop to create an initially open popover.- Type
string | null | undefined
handleMenu.Handle<Payload>—
Menu.Handle<Payload>- Name
- Description
A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu’s open state.
- Type
Menu.Handle<Payload> | undefined
loopFocusbooleantrue
boolean- Name
- Description
Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
- Type
boolean | undefined- Default
true
modalbooleantrue
boolean- Name
- Description
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.
- Type
boolean | undefined- Default
true
onOpenChangeCompletefunction—
function- Description
Event handler called after any animations complete when the menu is closed.
- Type
((open: boolean) => void) | undefined
triggerIdstring | null—
string | null- Name
- Description
ID of the trigger that the popover is associated with. This is useful in conjunction with the
openprop to create a controlled popover. There’s no need to specify this prop when the popover is uncontrolled (that is, when theopenprop is not set).- Type
string | null | undefined
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
orientationMenu.Root.Orientation'vertical'
Menu.Root.Orientation- Name
- Description
The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.
- Type
Menu.Root.Orientation | undefined- Default
'vertical'
children| React.ReactNode
| PayloadChildRenderFunction<Payload>—
| React.ReactNode
| PayloadChildRenderFunction<Payload>- Name
- Description
The content of the popover. This can be a regular React node or a render function that receives the
payloadof the active trigger.- Type
React.ReactNode | ((arg: { payload: unknown | undefined }) => ReactNode)<Payload> | undefined
Additional Types
Menu.Root.Props
Re-Export of Root props as MenuRootProps
Menu.Root.Actions
type MenuRootActions = { unmount: () => void; close: () => void };Menu.Root.ChangeEventReason
type MenuRootChangeEventReason =
| 'trigger-hover'
| 'trigger-focus'
| 'trigger-press'
| 'outside-press'
| 'focus-out'
| 'list-navigation'
| 'escape-key'
| 'item-press'
| 'close-press'
| 'sibling-open'
| 'cancel-open'
| 'imperative-action'
| 'none';Menu.Root.ChangeEventDetails
type MenuRootChangeEventDetails =
| {
reason: 'none';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-hover';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-focus';
event: FocusEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-press';
event:
| KeyboardEvent
| MouseEvent
| TouchEvent
| PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'outside-press';
event: MouseEvent | TouchEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'focus-out';
event: FocusEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'list-navigation';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'escape-key';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'item-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'close-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'sibling-open';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'cancel-open';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'imperative-action';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}Menu.Root.Orientation
type MenuRootOrientation = 'horizontal' | 'vertical';Trigger
A button that opens the menu.
Renders a <button> element.
handleMenu.Handle<Payload>—
Menu.Handle<Payload>- Name
- Description
A handle to associate the trigger with a menu.
- Type
Menu.Handle<Payload> | undefined
nativeButtonbooleantrue
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
payloadPayload—
Payload- Name
- Description
A payload to pass to the menu when it is opened.
- Type
Payload | undefined
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
openOnHoverboolean—
boolean- Name
- Description
Whether the menu should also open when the trigger is hovered.
- Type
boolean | undefined
delaynumber100
number- Name
- Description
How long to wait before the menu may be opened on hover. Specified in milliseconds.
Requires the
openOnHoverprop.- Type
number | undefined- Default
100
closeDelaynumber0
number- Name
- Description
How long to wait before closing the menu that was opened on hover. Specified in milliseconds.
Requires the
openOnHoverprop.- Type
number | undefined- Default
0
childrenReact.ReactNode—
React.ReactNode- Name
- Type
React.ReactNode | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Trigger.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Trigger.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Trigger.State, ) => ReactElement) | undefined
data-popup-open
data-pressed
Additional Types
Menu.Trigger.Props
Re-Export of Trigger props as MenuTriggerProps
Menu.Trigger.State
type MenuTriggerState = { open: boolean; disabled: boolean };Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>.
Renders a <div> element.
containerUnion—
Union- Name
- Description
A parent element to render the portal element into.
- Type
| HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Portal.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Portal.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether to keep the portal mounted in the DOM while the popup is hidden.
- Type
boolean | undefined- Default
false
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Portal.State, ) => ReactElement) | undefined
Additional Types
Menu.Portal.Props
Re-Export of Portal props as MenuPortalProps
Menu.Portal.State
type MenuPortalState = {};Backdrop
An overlay displayed beneath the menu popup.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Backdrop.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Backdrop.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Backdrop.State, ) => ReactElement) | undefined
data-open
data-closed
data-starting-style
data-ending-style
Additional Types
Menu.Backdrop.Props
Re-Export of Backdrop props as MenuBackdropProps
Menu.Backdrop.State
type MenuBackdropState = { open: boolean; transitionStatus: TransitionStatus };Positioner
Positions the menu popup against the trigger.
Renders a <div> element.
disableAnchorTrackingbooleanfalse
boolean- Description
Whether to disable the popup from tracking any layout shift of its positioning anchor.
- Type
boolean | undefined- Default
false
alignAlign'center'
Align- Name
- Description
How to align the popup relative to the specified side.
- Type
'start' | 'center' | 'end' | undefined- Default
'center'
alignOffsetnumber | OffsetFunction0
number | OffsetFunction- Name
- Description
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
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.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.
- Type
| number | ((data: { side: | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'; align: 'start' | 'center' | 'end'; anchor: { width: number; height: number }; positioner: { width: number; height: number }; }) => number) | undefined- Default
0- Example
<Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.width : anchor.height; }} />
sideSide'bottom'
Side- Name
- Description
Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
- Type
| 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | undefined- Default
'bottom'
sideOffsetnumber | OffsetFunction0
number | OffsetFunction- Name
- Description
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
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.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.
- Type
| number | ((data: { side: | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'; align: 'start' | 'center' | 'end'; anchor: { width: number; height: number }; positioner: { width: number; height: number }; }) => number) | undefined- Default
0- Example
<Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.height : anchor.width; }} />
arrowPaddingnumber5
number- Name
- Description
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.
- Type
number | undefined- Default
5
anchorUnion—
Union- Name
- Description
An element to position the popup against. By default, the popup will be positioned against the trigger.
- Type
| Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null) | null | undefined
collisionAvoidanceCollisionAvoidance—
CollisionAvoidance- Description
Determines how to handle collisions when positioning the popup.
- Type
CollisionAvoidance | undefined- Example
<Positioner collisionAvoidance={{ side: 'shift', align: 'shift', fallbackAxisSide: 'none', }} />
collisionBoundaryBoundary'clipping-ancestors'
Boundary- Description
An element or a rectangle that delimits the area that the popup is confined to.
- Type
Boundary | undefined- Default
'clipping-ancestors'
collisionPaddingPadding5
Padding- Name
- Description
Additional space to maintain from the edge of the collision boundary.
- Type
Padding | undefined- Default
5
stickybooleanfalse
boolean- Name
- Description
Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.
- Type
boolean | undefined- Default
false
positionMethod'absolute' | 'fixed''absolute'
'absolute' | 'fixed'- Name
- Description
Determines which CSS
positionproperty to use.- Type
'absolute' | 'fixed' | undefined- Default
'absolute'
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Positioner.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Positioner.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Positioner.State, ) => ReactElement) | undefined
data-open
data-closed
data-anchor-hidden
data-align
data-side
--anchor-height
The anchor’s height.
--anchor-width
The anchor’s width.
--available-height
The available height between the trigger and the edge of the viewport.
--available-width
The available width between the trigger and the edge of the viewport.
--transform-origin
The coordinates that this element is anchored to. Used for animations and transitions.
Additional Types
Menu.Positioner.Props
Re-Export of Positioner props as MenuPositionerProps
Menu.Positioner.State
type MenuPositionerState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
anchorHidden: boolean;
nested: boolean;
}Popup
A container for the menu items.
Renders a <div> element.
finalFocusUnion—
Union- Name
- Description
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, orkeyboard). Return an element to focus,trueto use the default behavior, orfalse/undefinedto do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( closeType: | 'mouse' | 'touch' | 'pen' | 'keyboard' | '', ) => boolean | void | HTMLElement | null) | undefined
childrenReact.ReactNode—
React.ReactNode- Name
- Type
React.ReactNode | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Popup.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Popup.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Popup.State, ) => ReactElement) | undefined
data-open
data-closed
data-align
data-instant
data-side
data-starting-style
data-ending-style
Additional Types
Menu.Popup.Props
Re-Export of Popup props as MenuPopupProps
Menu.Popup.State
type MenuPopupState = {
transitionStatus: TransitionStatus;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
open: boolean;
nested: boolean;
instant: 'dismiss' | 'click' | 'group' | undefined;
}Arrow
Displays an element positioned against the menu anchor.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Arrow.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Arrow.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Arrow.State, ) => ReactElement) | undefined
data-open
data-closed
data-uncentered
data-align
data-side
Additional Types
Menu.Arrow.Props
Re-Export of Arrow props as MenuArrowProps
Menu.Arrow.State
type MenuArrowState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
uncentered: boolean;
}Item
An individual interactive item in the menu.
Renders a <div> element.
labelstring—
string- Name
- Description
Overrides the text label to use when the item is matched during keyboard text navigation.
- Type
string | undefined
onClickfunction—
function- Name
- Description
The click handler for the menu item.
- Type
| (( event: BaseUIEvent< React.MouseEvent<HTMLDivElement, MouseEvent> >, ) => void) | undefined
closeOnClickbooleantrue
boolean- Name
- Description
Whether to close the menu when the item is clicked.
- Type
boolean | undefined- Default
true
nativeButtonbooleanfalse
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set totrueif the rendered element is a native button.- Type
boolean | undefined- Default
false
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Item.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Item.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Item.State, ) => ReactElement) | undefined
data-highlighted
data-disabled
Additional Types
Menu.Item.Props
Re-Export of Item props as MenuItemProps
Menu.Item.State
type MenuItemState = { disabled: boolean; highlighted: boolean };LinkItem
A link in the menu that can be used to navigate to a different page or section.
Renders an <a> element.
labelstring—
string- Name
- Description
Overrides the text label to use when the item is matched during keyboard text navigation.
- Type
string | undefined
closeOnClickbooleanfalse
boolean- Name
- Description
Whether to close the menu when the item is clicked.
- Type
boolean | undefined- Default
false
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.LinkItem.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.LinkItem.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.LinkItem.State, ) => ReactElement) | undefined
data-highlighted
Additional Types
Menu.LinkItem.Props
Re-Export of LinkItem props as MenuLinkItemProps
Menu.LinkItem.State
type MenuLinkItemState = { highlighted: boolean };SubmenuRoot
Groups all parts of a submenu. Doesn’t render its own HTML element.
defaultOpenbooleanfalse
boolean- Name
- Description
Whether the menu is initially open.
To render a controlled menu, use the
openprop instead.- Type
boolean | undefined- Default
false
openboolean—
boolean- Name
- Description
Whether the menu is currently open.
- Type
boolean | undefined
onOpenChangefunction—
function- Name
- Description
Event handler called when the menu is opened or closed.
- Type
| (( open: boolean, eventDetails: Menu.SubmenuRoot.ChangeEventDetails, ) => void) | undefined
highlightItemOnHoverbooleantrue
boolean- Description
Whether moving the pointer over items should highlight them. Disabling this prop allows CSS
:hoverto be differentiated from the:focus(data-highlighted) state.- Type
boolean | undefined- Default
true
actionsRef| React.RefObject<Menu.Root.Actions
| null>—
| React.RefObject<Menu.Root.Actions
| null>- Name
- Description
A ref to imperative actions.
unmount: When specified, the menu will not be unmounted when closed. Instead, theunmountfunction must be called to unmount the menu manually. Useful when the menu’s animation is controlled by an external library.close: When specified, the menu can be closed imperatively.
- Type
React.RefObject<Menu.Root.Actions | null> | undefined
closeParentOnEscbooleanfalse
boolean- Name
- Description
When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
- Type
boolean | undefined- Default
false
defaultTriggerIdstring | null—
string | null- Name
- Description
ID of the trigger that the popover is associated with. This is useful in conjunction with the
defaultOpenprop to create an initially open popover.- Type
string | null | undefined
handleMenu.Handle<unknown>—
Menu.Handle<unknown>- Name
- Description
A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu’s open state.
- Type
Menu.Handle<unknown> | undefined
loopFocusbooleantrue
boolean- Name
- Description
Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
- Type
boolean | undefined- Default
true
onOpenChangeCompletefunction—
function- Description
Event handler called after any animations complete when the menu is closed.
- Type
((open: boolean) => void) | undefined
triggerIdstring | null—
string | null- Name
- Description
ID of the trigger that the popover is associated with. This is useful in conjunction with the
openprop to create a controlled popover. There’s no need to specify this prop when the popover is uncontrolled (that is, when theopenprop is not set).- Type
string | null | undefined
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
orientationMenu.Root.Orientation'vertical'
Menu.Root.Orientation- Name
- Description
The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.
- Type
Menu.Root.Orientation | undefined- Default
'vertical'
children| React.ReactNode
| PayloadChildRenderFunction<unknown>—
| React.ReactNode
| PayloadChildRenderFunction<unknown>- Name
- Description
The content of the popover. This can be a regular React node or a render function that receives the
payloadof the active trigger.- Type
React.ReactNode | ((arg: { payload: unknown | undefined }) => ReactNode)<unknown> | undefined
Additional Types
Menu.SubmenuRoot.Props
Re-Export of SubmenuRoot props as MenuSubmenuRootProps
Menu.SubmenuRoot.State
type MenuSubmenuRootState = {};Menu.SubmenuRoot.ChangeEventReason
type MenuSubmenuRootChangeEventReason =
| 'trigger-hover'
| 'trigger-focus'
| 'trigger-press'
| 'outside-press'
| 'focus-out'
| 'list-navigation'
| 'escape-key'
| 'item-press'
| 'close-press'
| 'sibling-open'
| 'cancel-open'
| 'imperative-action'
| 'none';Menu.SubmenuRoot.ChangeEventDetails
type MenuSubmenuRootChangeEventDetails =
| {
reason: 'none';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-hover';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-focus';
event: FocusEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-press';
event:
| KeyboardEvent
| MouseEvent
| TouchEvent
| PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'outside-press';
event: MouseEvent | TouchEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'focus-out';
event: FocusEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'list-navigation';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'escape-key';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'item-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'close-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'sibling-open';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'cancel-open';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'imperative-action';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}SubmenuTrigger
A menu item that opens a submenu.
Renders a <div> element.
labelstring—
string- Name
- Description
Overrides the text label to use when the item is matched during keyboard text navigation.
- Type
string | undefined
onClickfunction—
function- Name
- Type
| (( event: BaseUIEvent< React.MouseEvent<HTMLDivElement, MouseEvent> >, ) => void) | undefined
nativeButtonbooleanfalse
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set totrueif the rendered element is a native button.- Type
boolean | undefined- Default
false
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
openOnHoverboolean—
boolean- Name
- Description
Whether the menu should also open when the trigger is hovered.
- Type
boolean | undefined
delaynumber100
number- Name
- Description
How long to wait before the menu may be opened on hover. Specified in milliseconds.
Requires the
openOnHoverprop.- Type
number | undefined- Default
100
closeDelaynumber0
number- Name
- Description
How long to wait before closing the menu that was opened on hover. Specified in milliseconds.
Requires the
openOnHoverprop.- Type
number | undefined- Default
0
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Menu.SubmenuTrigger.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.SubmenuTrigger.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.SubmenuTrigger.State, ) => ReactElement) | undefined
data-popup-open
data-highlighted
data-disabled
Additional Types
Menu.SubmenuTrigger.Props
Re-Export of SubmenuTrigger props as MenuSubmenuTriggerProps
Menu.SubmenuTrigger.State
type MenuSubmenuTriggerState = { disabled: boolean; highlighted: boolean; open: boolean };Group
Groups related menu items with the corresponding label.
Renders a <div> element.
childrenReact.ReactNode—
React.ReactNode- Name
- Description
The content of the component.
- Type
React.ReactNode | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.Group.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.Group.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.Group.State, ) => ReactElement) | undefined
Additional Types
Menu.Group.Props
Re-Export of Group props as MenuGroupProps
Menu.Group.State
type MenuGroupState = {};GroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.GroupLabel.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.GroupLabel.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.GroupLabel.State, ) => ReactElement) | undefined
Additional Types
Menu.GroupLabel.Props
Re-Export of GroupLabel props as MenuGroupLabelProps
Menu.GroupLabel.State
type MenuGroupLabelState = {};RadioGroup
Groups related radio items.
Renders a <div> element.
defaultValueany—
any- Name
- Description
The uncontrolled value of the radio item that should be initially selected.
To render a controlled radio group, use the
valueprop instead.- Type
any | undefined
valueany—
any- Name
- Description
The controlled value of the radio item that should be currently selected.
To render an uncontrolled radio group, use the
defaultValueprop instead.- Type
any | undefined
onValueChangefunction—
function- Name
- Description
Function called when the selected value changes.
- Type
| (( value: any, eventDetails: Menu.RadioGroup.ChangeEventDetails, ) => void) | undefined
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
childrenReact.ReactNode—
React.ReactNode- Name
- Description
The content of the component.
- Type
React.ReactNode | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.RadioGroup.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.RadioGroup.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.RadioGroup.State, ) => ReactElement) | undefined
Additional Types
Menu.RadioGroup.Props
Re-Export of RadioGroup props as MenuRadioGroupProps
Menu.RadioGroup.State
type MenuRadioGroupState = { disabled: boolean };Menu.RadioGroup.ChangeEventReason
type MenuRadioGroupChangeEventReason =
| 'trigger-hover'
| 'trigger-focus'
| 'trigger-press'
| 'outside-press'
| 'focus-out'
| 'list-navigation'
| 'escape-key'
| 'item-press'
| 'close-press'
| 'sibling-open'
| 'cancel-open'
| 'imperative-action'
| 'none';Menu.RadioGroup.ChangeEventDetails
type MenuRadioGroupChangeEventDetails =
| {
reason: 'none';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-hover';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-focus';
event: FocusEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-press';
event:
| KeyboardEvent
| MouseEvent
| TouchEvent
| PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'outside-press';
event: MouseEvent | TouchEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'focus-out';
event: FocusEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'list-navigation';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'escape-key';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'item-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'close-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'sibling-open';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'cancel-open';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'imperative-action';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}RadioItem
A menu item that works like a radio button in a given group.
Renders a <div> element.
labelstring—
string- Name
- Description
Overrides the text label to use when the item is matched during keyboard text navigation.
- Type
string | undefined
value*any—
any- Name
- Description
Value of the radio item. This is the value that will be set in the Menu.RadioGroup when the item is selected.
- Type
any
onClickfunction—
function- Name
- Description
The click handler for the menu item.
- Type
| (( event: BaseUIEvent< React.MouseEvent<HTMLDivElement, MouseEvent> >, ) => void) | undefined
closeOnClickbooleanfalse
boolean- Name
- Description
Whether to close the menu when the item is clicked.
- Type
boolean | undefined- Default
false
nativeButtonbooleanfalse
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set totrueif the rendered element is a native button.- Type
boolean | undefined- Default
false
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.RadioItem.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.RadioItem.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.RadioItem.State, ) => ReactElement) | undefined
data-checked
data-unchecked
data-highlighted
data-disabled
Additional Types
Menu.RadioItem.Props
Re-Export of RadioItem props as MenuRadioItemProps
Menu.RadioItem.State
type MenuRadioItemState = { disabled: boolean; highlighted: boolean; checked: boolean };RadioItemIndicator
Indicates whether the radio item is selected.
Renders a <span> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Menu.RadioItemIndicator.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.RadioItemIndicator.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether to keep the HTML element in the DOM when the radio item is inactive.
- Type
boolean | undefined- Default
false
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.RadioItemIndicator.State, ) => ReactElement) | undefined
data-checked
data-unchecked
data-disabled
data-starting-style
data-ending-style
Additional Types
Menu.RadioItemIndicator.Props
Re-Export of RadioItemIndicator props as MenuRadioItemIndicatorProps
Menu.RadioItemIndicator.State
type MenuRadioItemIndicatorState = {
checked: boolean;
disabled: boolean;
highlighted: boolean;
transitionStatus: TransitionStatus;
};CheckboxItem
A menu item that toggles a setting on or off.
Renders a <div> element.
labelstring—
string- Name
- Description
Overrides the text label to use when the item is matched during keyboard text navigation.
- Type
string | undefined
defaultCheckedbooleanfalse
boolean- Name
- Description
Whether the checkbox item is initially ticked.
To render a controlled checkbox item, use the
checkedprop instead.- Type
boolean | undefined- Default
false
checkedboolean—
boolean- Name
- Description
Whether the checkbox item is currently ticked.
To render an uncontrolled checkbox item, use the
defaultCheckedprop instead.- Type
boolean | undefined
onCheckedChangefunction—
function- Name
- Description
Event handler called when the checkbox item is ticked or unticked.
- Type
| (( checked: boolean, eventDetails: Menu.CheckboxItem.ChangeEventDetails, ) => void) | undefined
onClickfunction—
function- Name
- Description
The click handler for the menu item.
- Type
| (( event: BaseUIEvent< React.MouseEvent<HTMLDivElement, MouseEvent> >, ) => void) | undefined
closeOnClickbooleanfalse
boolean- Name
- Description
Whether to close the menu when the item is clicked.
- Type
boolean | undefined- Default
false
nativeButtonbooleanfalse
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set totrueif the rendered element is a native button.- Type
boolean | undefined- Default
false
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Menu.CheckboxItem.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.CheckboxItem.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.CheckboxItem.State, ) => ReactElement) | undefined
data-checked
data-unchecked
data-highlighted
data-disabled
Additional Types
Menu.CheckboxItem.Props
Re-Export of CheckboxItem props as MenuCheckboxItemProps
Menu.CheckboxItem.State
type MenuCheckboxItemState = { disabled: boolean; highlighted: boolean; checked: boolean };Menu.CheckboxItem.ChangeEventReason
type MenuCheckboxItemChangeEventReason =
| 'trigger-hover'
| 'trigger-focus'
| 'trigger-press'
| 'outside-press'
| 'focus-out'
| 'list-navigation'
| 'escape-key'
| 'item-press'
| 'close-press'
| 'sibling-open'
| 'cancel-open'
| 'imperative-action'
| 'none';Menu.CheckboxItem.ChangeEventDetails
type MenuCheckboxItemChangeEventDetails =
| {
reason: 'none';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-hover';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-focus';
event: FocusEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-press';
event:
| KeyboardEvent
| MouseEvent
| TouchEvent
| PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'outside-press';
event: MouseEvent | TouchEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'focus-out';
event: FocusEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'list-navigation';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'escape-key';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'item-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'close-press';
event: KeyboardEvent | MouseEvent | PointerEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'sibling-open';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'cancel-open';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'imperative-action';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}CheckboxItemIndicator
Indicates whether the checkbox item is ticked.
Renders a <span> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Menu.CheckboxItemIndicator.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Menu.CheckboxItemIndicator.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether to keep the HTML element in the DOM when the checkbox item is not checked.
- Type
boolean | undefined- Default
false
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Menu.CheckboxItemIndicator.State, ) => ReactElement) | undefined
data-checked
data-unchecked
data-disabled
data-starting-style
data-ending-style
Additional Types
Menu.CheckboxItemIndicator.Props
Re-Export of CheckboxItemIndicator props as MenuCheckboxItemIndicatorProps
Menu.CheckboxItemIndicator.State
type MenuCheckboxItemIndicatorState = {
checked: boolean;
disabled: boolean;
highlighted: boolean;
transitionStatus: TransitionStatus;
};Separator
A separator element accessible to screen readers.
Renders a <div> element.
orientationOrientation'horizontal'
Orientation- Name
- Description
The orientation of the separator.
- Type
'horizontal' | 'vertical' | undefined- Default
'horizontal'
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: SeparatorState) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: SeparatorState, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: SeparatorState, ) => ReactElement) | undefined
Additional Types
Menu.Separator.Props
Re-Export of Separator props as MenuSeparatorProps
Menu.Separator.State
type MenuSeparatorState = {
orientation: 'horizontal' | 'vertical';
}createHandle
Creates a new handle to connect a Menu.Root with detached Menu.Trigger components.
Return value
Menu.Handle<Payload>Handle
Properties
isOpenbooleanreadonly
boolean- Name
- Description
Indicates whether the menu is currently open.
- Type
boolean- Modifiers
readonly
Methods
open(triggerId)void
- Name
- Description
Opens the menu and associates it with the trigger with the given id. The trigger must be a Menu.Trigger component with this handle passed as a prop.
- Parameters
triggerId—stringID of the trigger to associate with the menu.
- Returns
void
close()void
- Name
- Description
Closes the menu.
- Returns
void