<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Menu

A dropdown menu of buttons and/or links.
styleKeys: popoverstyleKeys: listbox

Use Menu...

  • To show set of actions available to a user when there is a limited space constraint.

Don't use Menu...

  • To hide critical actions for a user to complete a task. Use Button instead.

  • Menu consists of a MenuTrigger that wraps another element (often a Button, but it can be anything).
  • When that trigger is clicked, it launches a MenuPopover.
  • MenuPopover holds a MenuList, which contains one or more MenuItem children.
  • Each MenuItem acts as a button by default, but you can have it act as a link instead (see below).
  • Menu shares code with Listbox, and behaves similarly: to detect a user interaction with the Menu, use an onChange handler on the Menu itself.

The preview has been updated.

Icons

A MenuItem may contain an icon, which can help users discern the difference between options faster.

The preview has been updated.

Sections

Use MenuSection to display a section title to wrap a group of MenuItems. Each MenuSection requires a title and a key prop.

The preview has been updated.

Use an href prop on a MenuItem to make it act as a link instead of a button.

The preview has been updated.

Content

  • Use clear, concise labels to describe the action being performed by the Menu.
  • Use sentence case.
  • Do not use punctuation.

Icons

Icons should be size 20p.

Number of actions

Use between 2-7 actions. On smaller mobile devices, 2-4 actions typically fits nicely on a single viewport.

Menu
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
onChange((value: string | number) => void)false
Callback function that gets triggered when the value changes (for backward compatibility).
null

MenuTrigger
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.

MenuPopover
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
childrenReactNodefalse
The content to be displayed within the popover.
null
placementPlacementfalse
The placement of the popover. eg: "bottom start", "top end", "top", "bottom"
bottom start
offsetnumberfalse
The offset distance from the trigger element.
null
isNonModalbooleanfalse
Specifies whether the popover is used in a non-modal context.
null
hideArrowbooleanfalse
Specifies whether to hide the arrow of the popover.
true
fullBleedbooleanfalse
Specifies whether the popover should take up the full available width.
null
labelTextstringfalse
The label text for accessibility.
null
portalContainerElementfalse
The container for the portal where the popover is rendered.
null

MenuItem
This component is implemented using the <li /> as the root element. You can utilize the native attributes supported by <li /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
labelReactNodeLikefalse
The contents to render inside the ListboxButton. Can include JSX
null
disabledboolean | nullfalse
Whether or not the option is disabled.
null
textValuestring | nullfalse
The option's human-readable string. Required if using JSX inside of an option
null
withThumbnailboolean | nullfalse
Whether or not the option has a thumbnail.
null


Related

Was this page useful?

Thanks for your feedback!

Feel free to include your name if you wish to have a follow up conversation.


Published: Feb 8, 2024Last updated: Oct 17, 2024