Menu
Combine a list of secondary actions into single interactive area
Import
Source
Docs
Package
Usage
Controlled
Dropdown opened state can be controlled with opened
and onChange
props:
Show menu on hover
Set trigger="hover"
to reveal dropdown when hovers over menu target and dropdown.
closeDelay
and openDelay
props can be used to control open and close delay in ms.
Note that:
- If you set
closeDelay={0}
then menu will close before user will reach dropdown, setoffset={0}
to remove space between target element and dropdown - Menu with
trigger="hover"
is not accessible – users that navigate with keyboard will not be able to use it
Disabled items
Dropdown position
Transitions
Menu dropdown can be animated with any of premade transitions from Transition component:
Custom component as Menu.Item
By default, Menu.Item
renders as button element, to change that set component
prop:
Custom component as target
Styles API
Menu
supports Styles API, you can add styles to any inner element of the component withclassNames
prop. Follow Styles API documentation to learn more.
Component Styles API
Hover over selectors to highlight corresponding elements
Accessibility
Menu follows WAI-ARIA recommendations:
- Dropdown element has
role="menu"
andaria-labelledby="target-id"
attributes - Target element has
aria-haspopup="menu"
,aria-expanded
,aria-controls="dropdown-id"
attributes - Menu item has
role="menuitem"
attribute
Supported target elements
Uncontrolled Menu with trigger="click"
(default) will be accessible only when used with button
element or component that renders it (Button, ActionIcon, etc.).
Other elements will not support Space
and Enter
key presses.
Hover menu
Menu with trigger="hover"
is not accessible – it cannot be accessed with keyboard,
use it only if you do not care about accessibility.
Keyboard interactions
Key | Description | Condition |
Escape | Closes dropdown | Focus within dropdown |
Space/Enter | Opens/closes dropdown | Focus on target element |
ArrowUp | Moves focus to previous menu item | Focus within dropdown |
ArrowDown | Moves focus to next menu item | Focus within dropdown |
Home | Moves focus to first menu item | Focus within dropdown |
End | Moves focus to last menu item | Focus within dropdown |