Menu
A list of actions in a dropdown, enhanced with keyboard navigation.
API reference
Import the component and place its parts the following way:
Anatomy
import { Menu } from '@base-ui-components/react/menu';
<Menu.Root>
<Menu.Trigger />
<Menu.Positioner>
<Menu.Popup>
<Menu.Arrow />
<Menu.Item />
<Menu.Separator />
<Menu.Group>
<Menu.GroupLabel />
</Menu.Group>
<Menu.RadioGroup>
<Menu.RadioItem />
</Menu.RadioGroup>
<Menu.CheckboxItem />
{/* Submenu */}
<Menu.Root>
<Menu.SubmenuTrigger />
<Menu.Positioner>
<Menu.Popup>...</Menu.Popup>
</Menu.Positioner>
</Menu.Root>
</Menu.Popup>
</Menu.Positioner>
</Menu.Root>
Root
Prop | Type | Default | |
---|---|---|---|
closeParentOnEsc | boolean | true | |
defaultOpen | boolean | false | |
delay | number | 100 | |
disabled | boolean | false | |
loop | boolean | true | |
onOpenChange | (open, event) => void | undefined | |
open | boolean | undefined | |
openOnHover | boolean | undefined | |
orientation | 'horizontal' | 'vertical' | 'vertical' |
Trigger
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
disabled | boolean | false | |
label | string | undefined | |
render | | React.ReactElement | undefined |
Positioner
Renders the element that positions the Menu popup.
Prop | Type | Default | |
---|---|---|---|
align | 'start' | 'center' | 'end' | 'center' | |
alignOffset | number | 0 | |
anchor | | React.Ref | undefined | |
arrowPadding | number | 5 | |
className | string | (state) => string | undefined | |
collisionBoundary | | 'clippingAncestors' | 'clipping-ancestors' | |
collisionPadding | number | Rect | 5 | |
container | React.Ref | HTMLElement | null | undefined | |
keepMounted | boolean | false | |
positionMethod | 'absolute' | 'fixed' | 'absolute' | |
render | | React.ReactElement | undefined | |
side | 'top' | 'bottom' | 'left' | 'right' | 'bottom' | |
sideOffset | number | 0 | |
sticky | boolean | false |
CSS Variable | Type | |
---|---|---|
--anchor-height | number | |
--anchor-width | number | |
--available-height | number | |
--available-width | number | |
--transform-origin | string |
Popup
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
id | string | undefined | |
render | | React.ReactElement | undefined |
Arrow
Renders an arrow that points to the center of the anchor element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
hideWhenUncentered | boolean | false | |
render | | React.ReactElement | undefined |
Item
An unstyled menu item to be used within a Menu.
Prop | Type | Default | |
---|---|---|---|
closeOnClick | boolean | true | |
disabled | boolean | false | |
id | string | undefined | |
label | string | undefined | |
onClick | (event) => void | undefined |
Group
Prop | Type | Default | |
---|---|---|---|
children | React.ReactNode | undefined | |
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Group Label
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Radio Group
Prop | Type | Default | |
---|---|---|---|
children | React.ReactNode | undefined | |
className | string | (state) => string | undefined | |
defaultValue | any | undefined | |
onValueChange | (value, event) => void | () => {} | |
render | | React.ReactElement | undefined | |
value | any | undefined |
Radio Item
An unstyled radio menu item to be used within a Menu.
Prop | Type | Default | |
---|---|---|---|
value | any | undefined | |
closeOnClick | boolean | true | |
disabled | boolean | false | |
id | string | undefined | |
label | string | undefined | |
onClick | (event) => void | undefined |
Radio Item Indicator
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | true | |
render | | React.ReactElement | undefined |
Checkbox Item
An unstyled checkbox menu item to be used within a Menu.
Prop | Type | Default | |
---|---|---|---|
checked | boolean | undefined | |
closeOnClick | boolean | true | |
defaultChecked | boolean | false | |
disabled | boolean | false | |
id | string | undefined | |
label | string | undefined | |
onCheckedChange | function | undefined | |
onClick | (event) => void | undefined |
Checkbox Item Indicator
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | true | |
render | | React.ReactElement | undefined |
Submenu Trigger
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
disabled | boolean | false | |
label | string | undefined | |
render | | React.ReactElement | undefined |