Menu
A menu of actions (role="menu"), in one of two forms:
- **Static menu** โ Menu.Item/Menu.Divider children render inline inside the role="menu" element. The menu itself is not a tab stop: one item is (the last focused enabled item, else the first enabled one). When every item is disabled, the menu element holds the tab stop instead, so keyboard and screen-reader users still reach it. Arrow keys, Home/End and typeahead move between enabled items; Enter and Space activate the focused item (a Space typed within 500 ms of a typeahead character continues the search instead).
- **Popup menu** โ with Menu.Trigger and Menu.Popover children, or whenever open, defaultOpen or onOpenChange is passed (even false), the root renders no element of its own: the trigger opens the portaled Menu.Popover, item activation returns focus to the trigger and closes it (focus is on the trigger before the menu goes, so a Dialog the item opens returns focus there when it closes), unless persistOnItemClick (or the item's own persistOnClick) keeps it open. Open state is open/defaultOpen/onOpenChange. With openOnHover a mouse pointer resting on the trigger opens it without moving focus; with openOnContext the trigger is a context-menu region (a right click, Shift+F10 or the ContextMenu key opens the menu there).
- **Submenus** โ a <Menu> rendered in a menu list (inside Menu.Popover, or among the items of a static menu) is a submenu. Its Menu.Trigger wraps a Menu.Item, which becomes the submenu's trigger item (aria-haspopup="menu", a chevron that mirrors in RTL): tsx <Menu.Popover> <Menu> <Menu.Trigger><Menu.Item>Open recent</Menu.Item></Menu.Trigger> <Menu.Popover><Menu.Item>report.docx</Menu.Item></Menu.Popover> </Menu> </Menu.Popover> ArrowRight (ArrowLeft in RTL), Enter, Space, a click, or the mouse resting on the item opens the submenu (the keys and the click move focus to its first item); ArrowLeft (ArrowRight in RTL) and Escape close only that submenu and return focus to its item; item activation and Tab close every level and put focus on the root trigger (under a static menu, on the submenu's trigger item). One submenu of a menu is open at a time. It works in static menus too. A Menu inside a Popover or Dialog opened from an item is a root menu of its own, not a submenu. Menu.SplitGroup puts an action and the button of its submenu in one row.
**Checked values**: Menu.ItemCheckbox, Menu.ItemRadio and Menu.ItemSwitch are bound by name and value to the Menu's checkedValues (defaultCheckedValues, onCheckedValuesChange), in static and popup menus alike: unlike open, they do not make a Menu a popup menu. Space changes a checkable item and keeps the menu open; Enter and a click change it and close a popup menu. A submenu shares its parent's checked values unless it sets checkedValues or defaultCheckedValues of its own. Menu.Group and Menu.GroupHeader label a set of items; Menu.ItemLink navigates. The item labels line up: once an item of a menu shows a check or an icon, every item keeps that column.
**Popup detection**: Menu looks for Menu.Trigger/Menu.Popover (also under their flat names from a Server Component) among its direct children and inside Fragments only. When they are wrapped in another element or component, pass open, defaultOpen or onOpenChange to force popup mode; otherwise the static role="menu" element is rendered around them (development warning). A popup menu renders no root element, so className, ref and other DOM props on Menu are ignored (development warning): put them on Menu.Popover. Items rendered in a popup menu outside Menu.Popover have no role="menu" parent (development warning).
**Items of your own**: an element with role="menuitem" among the items is an item of the menu (arrow keys, typeahead and the pointer reach it). useMenuContext gives it close(), which closes the menu as a built-in item does, and useMenuListContext the icon and check columns that line its label up with the others.
Sub-components are also exported under flat names (MenuItem, MenuDivider, MenuTrigger, MenuPopover, MenuItemCheckbox, MenuItemRadio, MenuItemSwitch, MenuItemLink, MenuGroup, MenuGroupHeader, MenuSplitGroup): React Server Components import those, because dotted access (Menu.Item) needs a client file.
Examples
Default
export const Default: Story = {};With Icons
export const WithIcons: Story = {
args: {
'aria-label': 'Edit',
children: (
<>
<Menu.Item icon={{ children: 'โ๏ธ' }}>Cut</Menu.Item>
<Menu.Item icon={{ children: '๐' }}>Copy</Menu.Item>
<Menu.Item icon={{ children: '๐' }}>Paste</Menu.Item>
</>
),
},
};With Disabled
export const WithDisabled: Story = {
args: {
'aria-label': 'Edit',
children: (
<>
<Menu.Item>Undo</Menu.Item>
<Menu.Item>Redo</Menu.Item>
<Menu.Item disabled>Paste (empty clipboard)</Menu.Item>
</>
),
},
};With Divider
export const WithDivider: Story = {
args: {
children: (
<>
<Menu.Item>New File</Menu.Item>
<Menu.Item>Open File</Menu.Item>
<Menu.Divider />
<Menu.Item>Save</Menu.Item>
<Menu.Item>Save As</Menu.Item>
<Menu.Divider />
<Menu.Item>Exit</Menu.Item>
</>
),
},
};With Shortcuts
export const WithShortcuts: Story = {
args: {
children: (
<>
<Menu.Item shortcut="Ctrl+N">New File</Menu.Item>
<Menu.Item shortcut="Ctrl+O">Open File</Menu.Item>
<Menu.Divider />
<Menu.Item shortcut="Ctrl+S">Save</Menu.Item>
<Menu.Item shortcut="Ctrl+Shift+S">Save As</Menu.Item>
</>
),
},
};With Trigger
export const WithTrigger: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<Button>Actions</Button>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()} shortcut="Ctrl+E">
Edit
</Menu.Item>
<Menu.Item onClick={fn()}>Duplicate</Menu.Item>
<Menu.Divider />
<Menu.Item disabled>Archive</Menu.Item>
<Menu.Item onClick={fn()}>Delete</Menu.Item>
</Menu.Popover>
</>
),
},
};Long Menu
export const LongMenu: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<Button>Commands</Button>
</Menu.Trigger>
<Menu.Popover>
{LONG_MENU_ITEMS.map((label) => (
<Menu.Item key={label} onClick={fn()}>
{label}
</Menu.Item>
))}
</Menu.Popover>
</>
),
},
};Long Menu Max Height
export const LongMenuMaxHeight: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<Button>Commands</Button>
</Menu.Trigger>
<Menu.Popover className="max-h-64">
{LONG_MENU_ITEMS.map((label) => (
<Menu.Item key={label} onClick={fn()}>
{label}
</Menu.Item>
))}
</Menu.Popover>
</>
),
},
};Checkbox Items
export const CheckboxItems: Story = {
args: {
'aria-label': undefined,
defaultCheckedValues: { view: ['ruler', 'status-bar'] },
children: (
<>
<Menu.Trigger>
<Button>View</Button>
</Menu.Trigger>
<Menu.Popover>{viewItems}</Menu.Popover>
</>
),
},
};Radio Items
export const RadioItems: Story = {
args: {
'aria-label': undefined,
defaultCheckedValues: { sort: ['modified'] },
children: (
<>
<Menu.Trigger>
<Button>Sort</Button>
</Menu.Trigger>
<Menu.Popover>
<Menu.Group>
<Menu.GroupHeader>Sort by</Menu.GroupHeader>
{sortItems}
</Menu.Group>
</Menu.Popover>
</>
),
},
};Switch Items
export const SwitchItems: Story = {
args: {
'aria-label': undefined,
persistOnItemClick: true,
defaultCheckedValues: { editor: ['autosave', 'word-wrap'] },
children: (
<>
<Menu.Trigger>
<Button>Editor settings</Button>
</Menu.Trigger>
<Menu.Popover>
<Menu.ItemSwitch name="editor" value="autosave">
Autosave
</Menu.ItemSwitch>
<Menu.ItemSwitch name="editor" value="word-wrap">
Word wrap
</Menu.ItemSwitch>
<Menu.ItemSwitch name="editor" value="minimap">
Minimap
</Menu.ItemSwitch>
</Menu.Popover>
</>
),
},
};Mixed Columns
export const MixedColumns: Story = {
args: {
'aria-label': 'Format',
defaultCheckedValues: { format: ['bold'] },
children: (
<>
<Menu.ItemCheckbox name="format" value="bold" shortcut="Ctrl+B">
Bold
</Menu.ItemCheckbox>
<Menu.ItemCheckbox name="format" value="italic" shortcut="Ctrl+I">
Italic
</Menu.ItemCheckbox>
<Menu.Divider />
<Menu.Item icon={{ children: 'โ๏ธ' }} shortcut="Ctrl+X">
Cut
</Menu.Item>
<Menu.Item icon={{ children: '๐' }} shortcut="Ctrl+C">
Copy
</Menu.Item>
<Menu.Item shortcut="Ctrl+V">Paste</Menu.Item>
<Menu.Divider />
<Menu.ItemSwitch name="format" value="spellcheck">
Check spelling
</Menu.ItemSwitch>
</>
),
},
};Static Checkable
export const StaticCheckable: Story = {
args: {
'aria-label': 'View options',
defaultCheckedValues: { view: ['gridlines'], sort: ['name'] },
children: (
<>
<Menu.Group aria-label="Show">{viewItems}</Menu.Group>
<Menu.Divider />
<Menu.Group>
<Menu.GroupHeader>Sort by</Menu.GroupHeader>
{sortItems}
</Menu.Group>
</>
),
},
};Controlled Checked Values
Showing: ruler. Sorted by: name.
export const ControlledCheckedValues: Story = {
args: {
'aria-label': 'View',
children: (
<>
{viewItems}
<Menu.Divider />
<Menu.Group>
<Menu.GroupHeader>Sort by</Menu.GroupHeader>
{sortItems}
</Menu.Group>
</>
),
},
render: (args) => <ControlledViewMenu {...args} />,
};Groups
export const Groups: Story = {
args: {
'aria-label': undefined,
defaultCheckedValues: { view: ['ruler'], sort: ['name'] },
children: (
<>
<Menu.Trigger>
<Button>View</Button>
</Menu.Trigger>
<Menu.Popover>
<Menu.Group>
<Menu.GroupHeader>Show</Menu.GroupHeader>
{viewItems}
</Menu.Group>
<Menu.Divider />
<Menu.Group>
<Menu.GroupHeader>Sort by</Menu.GroupHeader>
{sortItems}
</Menu.Group>
</Menu.Popover>
</>
),
},
};Link Items
export const LinkItems: Story = {
args: {
'aria-label': undefined,
children: (
<>
<Menu.Trigger>
<Button>Account</Button>
</Menu.Trigger>
<Menu.Popover>
<Menu.ItemLink href="#profile">Profile</Menu.ItemLink>
<Menu.ItemLink href="#settings" shortcut="Ctrl+,">
Settings
</Menu.ItemLink>
<Menu.ItemLink href="#billing" disabled>
Billing
</Menu.ItemLink>
<Menu.Divider />
<Menu.ItemLink
href="https://example.com/help"
target="_blank"
rel="noreferrer"
icon={{ children: 'โ' }}
>
Help center (opens in a new window)
</Menu.ItemLink>
</Menu.Popover>
</>
),
},
};Submenus
export const Submenus: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<MenuButton>File</MenuButton>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item shortcut="Ctrl+N">New</Menu.Item>
<Menu>
<Menu.Trigger>
<Menu.Item>Open recent</Menu.Item>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>report.docx</Menu.Item>
<Menu.Item onClick={fn()}>notes.txt</Menu.Item>
<Menu>
<Menu.Trigger>
<Menu.Item>Older</Menu.Item>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>archive-2025.zip</Menu.Item>
<Menu.Item onClick={fn()}>archive-2024.zip</Menu.Item>
</Menu.Popover>
</Menu>
</Menu.Popover>
</Menu>
<Menu>
<Menu.Trigger>
<Menu.Item>Share</Menu.Item>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Email</Menu.Item>
<Menu.Item onClick={fn()}>Copy link</Menu.Item>
</Menu.Popover>
</Menu>
<Menu.Divider />
<Menu.Item>Exit</Menu.Item>
</Menu.Popover>
</>
),
},
};Static With Submenu
export const StaticWithSubmenu: Story = {
args: {
'aria-label': 'Edit',
// A static menu is as wide as its container: this width leaves its submenus room beside it.
className: 'w-64',
children: (
<>
<Menu.Item shortcut="Ctrl+X">Cut</Menu.Item>
<Menu.Item shortcut="Ctrl+C">Copy</Menu.Item>
<Menu>
<Menu.Trigger>
<Menu.Item>Paste special</Menu.Item>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Text only</Menu.Item>
<Menu.Item onClick={fn()}>Keep formatting</Menu.Item>
</Menu.Popover>
</Menu>
<Menu.SplitGroup>
<Menu.Item onClick={fn()}>Find</Menu.Item>
<Menu>
<Menu.Trigger>
<Menu.Item aria-label="More find options" />
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Find next</Menu.Item>
<Menu.Item onClick={fn()}>Replaceโฆ</Menu.Item>
</Menu.Popover>
</Menu>
</Menu.SplitGroup>
</>
),
},
};Split Group
export const SplitGroup: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<MenuButton>File</MenuButton>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item>New</Menu.Item>
<Menu.SplitGroup>
<Menu.Item onClick={fn()} shortcut="Ctrl+S">
Save
</Menu.Item>
<Menu>
<Menu.Trigger>
<Menu.Item aria-label="More save options" />
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Save asโฆ</Menu.Item>
<Menu.Item onClick={fn()}>Save a copy</Menu.Item>
</Menu.Popover>
</Menu>
</Menu.SplitGroup>
<Menu.Item>Close</Menu.Item>
</Menu.Popover>
</>
),
},
};Exit Motion
export const ExitMotion: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<Button>Actions</Button>
</Menu.Trigger>
<Menu.Popover motion="transition-opacity duration-wave-fast data-[presence=exiting]:opacity-0 motion-reduce:transition-none">
<Menu.Item onClick={fn()}>Edit</Menu.Item>
<Menu.Item onClick={fn()}>Duplicate</Menu.Item>
<Menu.Item onClick={fn()}>Delete</Menu.Item>
</Menu.Popover>
</>
),
},
};Motion
export const Motion: Story = {
args: { 'aria-label': undefined, onOpenChange: fn() },
render: function MotionMenus({ children: _children, ...args }) {
return (
<div className="flex flex-wrap gap-2">
{motionCases(fadeAndZoom).map(({ label, motion }) => (
// The story renders one menu per case; every other arg is forwarded.
<Menu key={label} {...args}>
<Menu.Trigger>
<MenuButton>{label}</MenuButton>
</Menu.Trigger>
<Menu.Popover motion={motion}>
<Menu.Item onClick={fn()}>Edit</Menu.Item>
<Menu.Item onClick={fn()}>Duplicate</Menu.Item>
<Menu>
<Menu.Trigger>
<Menu.Item>Share</Menu.Item>
</Menu.Trigger>
<Menu.Popover motion={motion}>
<Menu.Item onClick={fn()}>Email</Menu.Item>
<Menu.Item onClick={fn()}>Copy link</Menu.Item>
</Menu.Popover>
</Menu>
</Menu.Popover>
</Menu>
))}
</div>
);
},
};Hover Menu
export const HoverMenu: Story = {
args: {
'aria-label': undefined,
openOnHover: true,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<MenuButton>View</MenuButton>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Zoom in</Menu.Item>
<Menu.Item onClick={fn()}>Zoom out</Menu.Item>
<Menu.Item onClick={fn()}>Actual size</Menu.Item>
</Menu.Popover>
</>
),
},
};Context Menu
export const ContextMenu: Story = {
args: {
'aria-label': undefined,
openOnContext: true,
defaultCheckedValues: { flags: ['synced'] },
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<div
aria-keyshortcuts="Shift+F10"
className="flex w-72 flex-col items-stretch gap-1 rounded-md border border-wave-border p-2"
>
<p className="px-2 text-wave-caption-1 text-wave-muted-foreground">
Right-click a file, or press Shift+F10 on it.
</p>
{FILES.map((file) => (
<Button key={file} appearance="subtle" className="justify-start">
{file}
</Button>
))}
</div>
</Menu.Trigger>
<Menu.Popover aria-label="File actions">
<Menu.Item onClick={fn()}>Open</Menu.Item>
<Menu.Item onClick={fn()}>Rename</Menu.Item>
<Menu.Divider />
<Menu.ItemCheckbox name="flags" value="pinned">
Pinned
</Menu.ItemCheckbox>
<Menu.ItemCheckbox name="flags" value="synced">
Available offline
</Menu.ItemCheckbox>
<Menu.Divider />
<Menu.Item onClick={fn()}>Delete</Menu.Item>
</Menu.Popover>
</>
),
},
};Custom Target
export const CustomTarget: Story = {
args: { 'aria-label': undefined, onOpenChange: fn() },
render: (args) => <CustomTargetMenu {...args} />,
};Custom Menu Item
export const CustomMenuItem: Story = {
args: {
'aria-label': undefined,
onOpenChange: fn(),
defaultCheckedValues: { view: ['ruler'] },
children: (
<>
<Menu.Trigger>
<Button>New</Button>
</Menu.Trigger>
<Menu.Popover>
<TemplateItem
title="Blank document"
description="Start from an empty page"
onSelect={fn()}
/>
<TemplateItem
title="Meeting notes"
description="Agenda, decisions and actions"
onSelect={fn()}
/>
<Menu.Divider />
<Menu.Item icon={{ children: '๐' }} onClick={fn()}>
Open
</Menu.Item>
<Menu.ItemCheckbox name="view" value="ruler">
Show ruler
</Menu.ItemCheckbox>
</Menu.Popover>
</>
),
},
};Item Content
export const ItemContent: Story = {
args: {
'aria-label': 'Message',
children: (
<>
<Menu.Item subText="Mark as read and archive">Archive</Menu.Item>
<Menu.Item secondaryContent={<strong>12</strong>}>Reply to all</Menu.Item>
<Menu.Item shortcut="Ctrl+Shift+F">Forward</Menu.Item>
<Menu.Item disabled>Share (skipped)</Menu.Item>
<Menu.Item disabledFocusable subText="Ask the owner for access">
Delete (reachable)
</Menu.Item>
<Menu.Item>Print</Menu.Item>
</>
),
},
};Inline With Details
export const InlineWithDetails: Story = {
args: {
'aria-label': undefined,
inline: true,
closeOnScroll: true,
onOpenChange: fn(),
children: (
<>
<Menu.Trigger>
<Button>Actions</Button>
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Edit</Menu.Item>
<Menu.Item onClick={fn()}>Duplicate</Menu.Item>
</Menu.Popover>
</>
),
},
decorators: [
(Story) => (
<div style={{ position: 'relative', padding: 24, minHeight: 160 }}>
<Story />
</div>
),
],
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
children | React.ReactNode | Yes | Menu items and dividers (static menu), or a | |
open | boolean | No | Controlled open state of a popup menu ( | |
defaultOpen | boolean | No | Initial open state of an uncontrolled popup menu; a popup menu starts closed without it. Passing it, even | |
onOpenChange | (open: boolean, details?: MenuOpenChangeDetails) => void | No | Called with the next open state when the popup menu opens or closes (only on change), and with | |
closeOnScroll | boolean | No | false | Close the popup menu when anything outside it and its trigger scrolls, the page included ( |
inline | boolean | No | false | Render the popup where the |
mountNode | HTMLElement | null | No | the provider's portal container, else `document.body` | The element the popup is portaled into (the |
checkedValues | CheckedValues | No | Checked items of the menu's checkbox, radio and switch items, per group | |
defaultCheckedValues | CheckedValues | No | {} | Initial checked items for uncontrolled usage (gives a submenu its own state). |
onCheckedValuesChange | CheckedValuesChangeHandler | No | Called when an item changes the checked items (only on change): the new checked values of every group first, then | |
persistOnItemClick | boolean | No | false | Keep a popup menu open after any of its items is activated; an item's own |
openOnHover | boolean | No | false (true for a submenu) | Open the popup menu when a mouse pointer rests on its trigger, and close it once the pointer has been off the trigger and the menu for |
openDelay | number | No | 250 | Milliseconds a hovering mouse pointer rests on the trigger before the menu opens (mouse hover only). A submenu inherits its parent's, also from a static menu. |
closeDelay | number | No | 250 | Milliseconds before a hover-opened menu closes once the mouse pointer has left it and its trigger (mouse hover only). A submenu inherits its parent's, also from a static menu. |
openOnContext | boolean | No | false | Make |
ref | React.Ref<HTMLDivElement> | No | Ref to the static menu element ( |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
Menu.ItemMenu.DividerMenu.TriggerMenu.PopoverMenu.ItemCheckboxMenu.ItemRadioMenu.ItemSwitchMenu.ItemLinkMenu.GroupMenu.GroupHeaderMenu.SplitGroup
Stable class names
| Part | Class |
|---|---|
root | wave-menu |