Menu
A collapsible menu that reveals actions or navigation options when triggered, not a form input like a select, and designed for quick, contextual choices.
Installation
Install the component via the CLI in one command.
npx shadcn@latest add @intentui/menu
Composed components
When you install this component via the CLI, it automatically loads all composed components, so you donât need to add them individually.
Manual installation
Use this approach if you prefer to install and wire up the component yourself instead of using the CLI.
npm install react-aria-components @heroicons/react tailwind-merge tailwind-variants
Anatomy
import {
IconCommandRegular,
HomeIcon,
IconDeviceDesktop,
IconLogout,
MoonIcon,
IconSettings,
SunIcon,
} from "@heroicons/react"
import {
Menu,
MenuContent,
MenuHeader,
MenuItem,
MenuLabel,
MenuSection,
MenuSeparator,
MenuSubMenu,
MenuTrigger,
} from "@/components/ui/menu"<Menu>
<MenuTrigger>Open</MenuTrigger>
<MenuContent popover={{ placement: "bottom" }} className="min-w-52">
<MenuHeader separator>
<span className="block">Kurt Cobain</span>
<span className="font-normal text-muted-fg">@cobain</span>
</MenuHeader>
<MenuSection>
<MenuItem href="#dashboard">
<HomeIcon />
<MenuLabel>Dashboard</MenuLabel>
</MenuItem>
<MenuItem href="#settings">
<IconSettings />
<MenuLabel>Settings</MenuLabel>
</MenuItem>
</MenuSection>
<MenuSeparator />
<MenuItem>
<IconCommandRegular />
<MenuLabel>Command Menu</MenuLabel>
</MenuItem>
<MenuSubMenu>
<MenuItem>
<IconDeviceDesktop />
<MenuLabel>Switch theme</MenuLabel>
</MenuItem>
<MenuContent>
<MenuItem>
<IconDeviceDesktop />
<MenuLabel>System</MenuLabel>
</MenuItem>
<MenuItem>
<MoonIcon />
<MenuLabel>Dark</MenuLabel>
</MenuItem>
<MenuItem>
<SunIcon />
<MenuLabel>Light</MenuLabel>
</MenuItem>
</MenuContent>
</MenuSubMenu>
<MenuSeparator />
<MenuItem href="#contact-s">
<MenuLabel>Contact Support</MenuLabel>
</MenuItem>
<MenuSeparator />
<MenuItem href="#logout">
<IconLogout />
<MenuLabel>Log out</MenuLabel>
</MenuItem>
</MenuContent>
</Menu>Examples
Links
Integrating MenuItem with your frameworkâs link component is straightforward. Learn more in Client Side Routing.
Sub menu
Menu can be nested to display submenus.
Danger
Designate a menu item as dangerous.
With icon
Enhance menu items by adding icons.
Dynamic
Generate menu items dynamically.
Multiple
Display a selection of actions or options.
Single menu
Present a single list of options.
Section menu
Organize menu items into grouped sections.
Section-level selection
Organize menu items into grouped sections with level selection.
Arrow
Incorporate an arrow into the menu using the arrow from popover in the MenuContent component.
Disabled
Disable specific menu items.
Also, you can disable items directly in MenuContent by using the disabledKeys prop.
<MenuContent disabledKeys={['gsu']} />Menu label
In the examples above, you might notice that the MenuLabel component is used inconsistently. This is because it is not mandatory, but it is considered a best practice. Using MenuLabel ensures proper alignment between icons and text, especially when dealing with items that vary. For instance, one item might have an icon while another does not. Adding MenuLabel helps create a polished and consistent appearance.
Description
You can add details to menu items by using the MenuDescription component.
Open modal
Trigger a modal from a menu item. Refer to the modal demo for further information.
Component API
Menu
The Menu component controls the menu trigger and content.
MenuTrigger
The MenuTrigger component opens the menu.
| Prop | Type | Default |
|---|---|---|
className | string | - |
MenuContent
The MenuContent component renders menu items inside a popover.
| Prop | Type | Default |
|---|---|---|
className | string | - |
popover | Pick< PopoverContentProps, | "arrow" | "className" | "placement" | "offset" | "crossOffset" | "arrowBoundaryOffset" | "triggerRef" | "isOpen" | "onOpenChange" | "shouldFlip" > | - |
MenuSubMenu
The MenuSubMenu component opens a nested menu.
| Prop | Type | Default |
|---|---|---|
delay | number | 0 |
MenuHeader
The MenuHeader component renders header content inside a menu.
| Prop | Type | Default |
|---|---|---|
className | string | - |
separator | boolean | false |
MenuItem
The MenuItem component represents one menu option or action.
| Prop | Type | Default |
|---|---|---|
className | string | - |
intent | "danger" | "warning" | - |
MenuLabel
The MenuLabel component renders the primary text for a menu item.
| Prop | Type | Default |
|---|---|---|
className | string | - |
MenuDescription
The MenuDescription component renders supporting text for a menu item.
| Prop | Type | Default |
|---|---|---|
className | string | - |
MenuSection
The MenuSection component groups related menu items.
| Prop | Type | Default |
|---|---|---|
className | string | - |
label | string | - |
MenuSeparator
The MenuSeparator component separates menu groups.
| Prop | Type | Default |
|---|---|---|
className | string | - |
MenuShortcut
The MenuShortcut component displays a keyboard shortcut for a menu item.
| Prop | Type | Default |
|---|---|---|
className | string | - |
See the React Aria for the full API reference.
Unlock the full power ofIntent UI Design
Build modern web apps faster with 1000+ resources across components, blocks, patterns, templates, and starter kits.