Menu
A dropdown menu with support for items, groups, checkbox items, radio items, sub-menus, keyboard shortcuts, and separators.
$npx shadcn add @patchui/menu
Basic
Checkbox Items
Radio Items
Usage
import {
Button,
Menu,
MenuTrigger,
MenuPopup,
MenuItem,
MenuGroup,
MenuGroupLabel,
MenuCheckboxItem,
MenuRadioGroup,
MenuRadioItem,
MenuSeparator,
MenuShortcut,
MenuSub,
MenuSubTrigger,
MenuSubPopup,
} from "@patchui/react";
// Basic menu
<Menu>
<MenuTrigger render={<Button />}>Open Menu</MenuTrigger>
<MenuPopup>
<MenuItem>Profile</MenuItem>
<MenuItem>Settings</MenuItem>
<MenuSeparator />
<MenuItem variant="destructive">Log out</MenuItem>
</MenuPopup>
</Menu>
// With checkbox items
const [checked, setChecked] = useState(true);
<MenuCheckboxItem checked={checked} onCheckedChange={setChecked}>
Show Sidebar
</MenuCheckboxItem>
// With radio items
const [value, setValue] = useState("system");
<MenuRadioGroup value={value} onValueChange={setValue}>
<MenuRadioItem value="light">Light</MenuRadioItem>
<MenuRadioItem value="dark">Dark</MenuRadioItem>
<MenuRadioItem value="system">System</MenuRadioItem>
</MenuRadioGroup>Props
MenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "destructive" | "default" | Visual variant. Use destructive for dangerous actions like delete or log out. |
| inset | boolean | false | Adds left padding to align with items that have icons or indicators. |
| disabled | boolean | false | Disables the menu item. |
MenuPopup
| Prop | Type | Default | Description |
|---|---|---|---|
| side | "top" | "bottom" | "left" | "right" | "bottom" | Which side of the trigger the popup appears on. |
| sideOffset | number | 4 | Distance in pixels between the popup and trigger. |
| align | "start" | "center" | "end" | "center" | Alignment of the popup relative to the trigger. |
Compound Components
| Component | Description |
|---|---|
| Menu | Root component managing open/close state. |
| MenuTrigger | Element that opens the menu on click. |
| MenuPopup | Portal-rendered popup with positioner. |
| MenuItem | A single menu action. Supports variant and inset. |
| MenuGroup | Groups related items together. |
| MenuGroupLabel | Label for a group. Supports inset. |
| MenuCheckboxItem | A togglable item with a check indicator. |
| MenuRadioGroup | Container for mutually exclusive radio items. |
| MenuRadioItem | A radio option within a group. |
| MenuSeparator | A visual divider between sections. |
| MenuShortcut | Displays a keyboard shortcut hint, right-aligned. |
| MenuSub | Wrapper for a sub-menu. |
| MenuSubTrigger | Opens the sub-menu on hover. Supports inset. |
| MenuSubPopup | Portal-rendered popup for the sub-menu. |
Notes
- Keyboard navigation: Supports arrow keys, type-ahead, Home/End, Enter/Space, and Escape.
- Sub-menus: Nest
MenuSub>MenuSubTrigger+MenuSubPopupfor cascading menus. Sub-menus open on hover. - Portal rendering: The popup renders outside the DOM tree via a portal, so it appears above all other content.
- Inset alignment: Use the
insetprop onMenuItem,MenuGroupLabel, andMenuSubTriggerto align text with items that have icons or check indicators.