Add skidding or distance to customize menu offset position
EDITABLE EXAMPLE
<Menu>
<MenuButton>Select an option</MenuButton>
<MenuListskidding={20}distance={8}>
<MenuItem>List item</MenuItem>
<MenuItem>List item</MenuItem>
<MenuItem>List item</MenuItem>
</MenuList>
</Menu>
Accessibility
Keyboard Interaction
Key
Action
Enter or Space
When MenuButton receives focus, opens the menu and places focus on the first menu item
ArrowDown
When MenuButton receives focus, opens the menu and moves focus to the first menu item
ArrowUp
When MenuButton receives focus, opens the menu and moves focus to the last menu item
Escape
When the menu is open, closes the menu and sets focus to the MenuButton
ARIA roles
For MenuButton:
It has role set to button.
It has aria-haspopup set to either menu.
When the menu is displayed, MenuButton has aria-expanded set to true.
MenuButton has aria-controls set to the id of the MenuList.
For MenuList:
It contains the MenuItem has role menu.
Props
Menu
Name
Type
Default
Description
children
ReactNode
The children of the menu must be MenuButton or MenuList
isOpen
boolean
If true, the menu will be opened
autoSelect
boolean
false
The menu will select the first enabled item when it opens, the trigger item must be MenuButton
closeOnBlur
boolean
true
If true, the menu will close on outside click or blur
closeOnSelect
boolean
true
If true, the menu will close on menu item select
placement
PopperJS.placement
bottom-start
The placement of the MenuList. One of: 'top', 'bottom', 'right', 'left', 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'right-start', 'right-end', 'left-start', 'left-end'
MenuButton
Name
Type
children
ReactNode
onClick
React.MouseEventHandler
onKeyDown
React.KeyboardEventHandler
MenuList
Name
Type
Default
Description
children
ReactNode
The content of the MenuList, should be the MenuItem component
onClick
React.MouseEventHandler
Function to be called when you click on the menu item
onBlur
React.FocusEventHandler
Function to be called when you blur out of the menu list
skidding
number
0
Displaces the menu (in pixels) along the reference element. Used by popper.js
distance
number
0
Displaces the menu (in pixels) away from, or toward, the reference. Used by popper.js
MenuItem
Name
Type
Default
Description
disabled
boolean
If true, the menu item will be disabled
onClick
React.MouseEventHandler
Function that is called on click and enter/space keypress
onKeyDown
React.KeyboardEventHander
Function that is called on keydown
MenuGroup
Name
Type
Default
Description
children
ReactNode
The content of the menu group, should be the MenuItem component