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 is only available in the React API for SWAN.
- 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 aMenuList
, which contains one or moreMenuItem
children.- Each
MenuItem
acts as a button by default, but you can have it act as a link instead (see below). Menu
shares code withListbox
, and behaves similarly: to detect a user interaction with the Menu, use anonChange
handler on theMenu
itself.
The preview has been updated.
Icons
A MenuItem
may contain an icon, which can help users discern the difference between options faster.
When using HTML/JSX content inside the MenuItem
, include a textValue
prop whose value is an accessible label for the option.
The preview has been updated.
Sections
Use MenuSection
to display a section title to wrap a group of MenuItem
s. Each MenuSection
requires a title
and a key
prop.
The preview has been updated.
Links
Use an href
prop on a MenuItem
to make it act as a link instead of a button.
The preview has been updated.
Disabled
Use disabled
on Button
to prevent it from being opened, or on MenuItem
to indicate that individual options are not relevant or available within the user's current context.
The preview has been updated.