Menu
The Menu component provide end users with a list of options on temporary surfaces.
MenuArrow API
Import
import * as Menu from '@base_ui/react/Menu';
const MenuArrow = Menu.Arrow;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
hideWhenUncentered | bool | false | If |
render | element | func | - | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useMenuArrow
to change the default props of this component with the theme.MenuItem API
Import
import * as Menu from '@base_ui/react/Menu';
const MenuItem = Menu.Item;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
closeOnClick | bool | true | If |
disabled | bool | false | If |
id | string | - | The id of the menu item. |
label | string | - | A text representation of the menu item's content. Used for keyboard text navigation matching. |
onClick | func | - | The click handler for the menu item. |
ref
is forwarded to the root element.Theme default props
You can useMenuItem
to change the default props of this component with the theme.MenuPopup API
Import
import * as Menu from '@base_ui/react/Menu';
const MenuPopup = Menu.Popup;
Props of the native component are also available.
Name | Type | Description |
---|---|---|
className | func | string | Class names applied to the element or a function that returns them based on the component's state. |
id | string | The id of the popup element. |
render | element | func | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useMenuPopup
to change the default props of this component with the theme.MenuPositioner API
Import
import * as Menu from '@base_ui/react/Menu';
const MenuPositioner = Menu.Positioner;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
alignment | 'center' | 'end' | 'start' | 'center' | The alignment of the Menu element to the anchor element along its cross axis. |
alignmentOffset | number | 0 | The offset of the Menu element along its alignment axis. |
anchor | HTML element | object | func | - | The anchor element to which the Menu popup will be placed at. |
arrowPadding | number | 5 | Determines the padding between the arrow and the Menu popup's edges. Useful when the popover popup has rounded corners via |
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
collisionBoundary | HTML element | Array<HTML element> | string | { height?: number, width?: number, x?: number, y?: number } | 'clippingAncestors' | The boundary that the Menu element should be constrained to. |
collisionPadding | number | { bottom?: number, left?: number, right?: number, top?: number } | 5 | The padding of the collision boundary. |
container | HTML element | func | - | The container element to which the Menu popup will be appended to. |
hideWhenDetached | bool | false | If |
keepMounted | bool | false | Whether the menu popup remains mounted in the DOM while closed. |
positionStrategy | 'absolute' | 'fixed' | 'absolute' | The CSS position strategy for positioning the Menu popup element. |
render | element | func | - | A function to customize rendering of the component. |
side | 'bottom' | 'left' | 'right' | 'top' | 'bottom' | The side of the anchor element that the Menu element should align to. |
sideOffset | number | 0 | The gap between the anchor element and the Menu element. |
sticky | bool | false | If |
ref
is forwarded to the root element.Theme default props
You can useMenuPositioner
to change the default props of this component with the theme.MenuRoot API
Import
import * as Menu from '@base_ui/react/Menu';
const MenuRoot = Menu.Root;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
animated | bool | true | If |
closeParentOnEsc | bool | true | Determines if pressing the Esc key closes the parent menus. This is only applicable for nested menus. |
defaultOpen | bool | false | If |
delay | number | 100 | The delay in milliseconds until the menu popup is opened when |
dir | 'ltr' | 'rtl' | 'ltr' | The direction of the Menu (left-to-right or right-to-left). |
disabled | bool | false | If |
loop | bool | true | If |
onOpenChange | func | - | Callback fired when the component requests to be opened or closed. |
open | bool | - | Allows to control whether the dropdown is open. This is a controlled counterpart of |
openOnHover | bool | nested | Whether the menu popup opens when the trigger is hovered after the provided |
orientation | 'horizontal' | 'vertical' | 'vertical' | The orientation of the Menu (horizontal or vertical). |
MenuTrigger API
Import
import * as Menu from '@base_ui/react/Menu';
const MenuTrigger = Menu.Trigger;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
disabled | bool | false | If |
focusableWhenDisabled | bool | false | If |
label | string | - | Label of the button |
render | element | func | - | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useMenuTrigger
to change the default props of this component with the theme.SubmenuTrigger API
Import
import { SubmenuTrigger } from '@base_ui/react/Menu';
Name | Type | Default | Description |
---|---|---|---|
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
disabled | bool | false | If |
disableFocusOnHover | bool | false | If |
label | string | - | A text representation of the menu item's content. Used for keyboard text navigation matching. |
render | element | func | - | A function to customize rendering of the component. |