Skip to content
PrimitivesMenuMenu

Menu

Dropdown menu on Base UI: actions, checkbox and radio items, groups, shortcuts and submenus, with concentric radii and keyboard-aware motion.

Actions with icons, shortcuts, groups and a disabled item.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/menu.json

Usage

tsx
import {
  Menu,
  MenuContent,
  MenuItem,
  MenuSeparator,
  MenuShortcut,
  MenuTrigger,
} from "@/components/ui/chatcn/menu"

<Menu>
  <MenuTrigger render={<Button variant="outline">Actions</Button>} />
  <MenuContent>
    <MenuItem onClick={rename}>
      <PencilIcon />
      Rename
      <MenuShortcut>R</MenuShortcut>
    </MenuItem>
    <MenuSeparator />
    <MenuItem disabled>Delete thread</MenuItem>
  </MenuContent>
</Menu>

Put an icon first and a MenuShortcut last; both are styled for you. MenuLabel must sit inside a MenuGroup or MenuRadioGroup. Pass render to the trigger to use your own button.

Examples

Checkbox, radio and submenu

Checks sit in a reserved slot at the end of the row, so checking an item never shifts its label.

Radio and checkbox items with a submenu.

Parts

PartBase UI partNotes
MenuMenu.Rootopen, defaultOpen, onOpenChange, modal (default true)
MenuTriggerMenu.Triggerrender to use your own button
MenuContentPortal, Positioner, Popupside (bottom), align (start), sideOffset (6), alignOffset, container
MenuItemMenu.Iteminset lines up a label with iconed items, disabled
MenuCheckboxItemMenu.CheckboxItemchecked, onCheckedChange, closeOnClick
MenuRadioGroup, MenuRadioItemMenu.RadioGroup, Menu.RadioItemvalue, onValueChange
MenuGroup, MenuLabelMenu.Group, Menu.GroupLabelSentence case labels, never uppercase
MenuSeparatorSeparatorFull bleed hairline
MenuShortcutDecorative hint, hidden from screen readers
MenuSub, MenuSubTrigger, MenuSubContentSubmenuRoot, SubmenuTriggerOpens to the inline end, first item level with the trigger

Keyboard

KeyAction
Enter, Space, ArrowDownOpen from the trigger, focus the first item
ArrowUp, ArrowDownMove between items, looping
ArrowRight (ArrowLeft in RTL)Open a submenu
EscClose the topmost menu and return focus to its trigger
LettersJump to the item that starts with them

Accessibility

  • Roles, aria-expanded, aria-checked and roving focus come from Base UI Menu.
  • Shortcut hints are aria-hidden; the item text stays the accessible name.
  • Items grow to 44 px on touch screens. In forced colors the popup keeps an outline.

Motion

  • Enter: opacity, scale from 0.96 and 4 px of travel away from the trigger, 180 ms ease-chatcn-out, growing from --transform-origin. Exit: 140 ms to scale 0.98.
  • Opened or closed with the keyboard, Base UI sets data-instant and nothing animates.
  • Item highlight is instant: menus are used too often for an animated hover.
  • Reduced motion keeps the fade and drops the scale and travel.