- Implementation
- Custom Trigger Props
- TriggerReturnProps
Common Examples
Creating simple dropdown menus
TheMenu and Menu.Item components can be used to compose basic dropdown menus.Nesting menus in dropdowns
To create nested dropdown menus, simply add aMenu as a child of another Menu.Creating custom menu triggers
To use a custom trigger element, use thetrigger prop of the Menu, and omit the label prop (and any other prop meant to be passed to the default Button trigger).Creating custom nested menu triggers
Nested menus support thetrigger prop the same way root menus do. Spread all props onto your trigger element, including ref, className, and data-anv, so the nested item receives menu styling and participates in keyboard navigation. A custom trigger replaces the default nested button, including the submenu chevron — include that icon in your markup.React Accessibility
When using a custom trigger, make sure that the trigger:- Can receive focus via keyboard when tabbing.
- Opens the menu when the user presses enter.
- Closes the menu and returns focus to the trigger when the user presses escape.
role,data-anv, andtabIndexspread onto the element so the parent menu’s focus query includes them.- ArrowRight to open the submenu.
- ArrowLeft to close the submenu and return focus to the nested trigger.