Patch UI

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

PropTypeDefaultDescription
variant"default" | "destructive""default"Visual variant. Use destructive for dangerous actions like delete or log out.
insetbooleanfalseAdds left padding to align with items that have icons or indicators.
disabledbooleanfalseDisables the menu item.

MenuPopup

PropTypeDefaultDescription
side"top" | "bottom" | "left" | "right""bottom"Which side of the trigger the popup appears on.
sideOffsetnumber4Distance in pixels between the popup and trigger.
align"start" | "center" | "end""center"Alignment of the popup relative to the trigger.

Compound Components

ComponentDescription
MenuRoot component managing open/close state.
MenuTriggerElement that opens the menu on click.
MenuPopupPortal-rendered popup with positioner.
MenuItemA single menu action. Supports variant and inset.
MenuGroupGroups related items together.
MenuGroupLabelLabel for a group. Supports inset.
MenuCheckboxItemA togglable item with a check indicator.
MenuRadioGroupContainer for mutually exclusive radio items.
MenuRadioItemA radio option within a group.
MenuSeparatorA visual divider between sections.
MenuShortcutDisplays a keyboard shortcut hint, right-aligned.
MenuSubWrapper for a sub-menu.
MenuSubTriggerOpens the sub-menu on hover. Supports inset.
MenuSubPopupPortal-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 + MenuSubPopup for 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 inset prop on MenuItem, MenuGroupLabel, and MenuSubTrigger to align text with items that have icons or check indicators.