Prodular UI

Context menu

A menu that opens on right click or long press, with the same items, shortcuts and variants as Dropdown menu.

npx prodular-ui add context-menu

File actions

Right click the row. Shortcuts line up on the right.

Q4 board update.pdf2.4 MB, edited by Tom BeckerRight click

Checkbox and radio items

Right click the canvas

Anatomy

<ContextMenu>  <ContextMenuTrigger className="rounded-xl border border-dashed p-6">Q4 board update.pdf</ContextMenuTrigger>  <ContextMenuContent className="w-56">    <ContextMenuItem>      <PencilIcon />      Rename      <ContextMenuShortcut>F2</ContextMenuShortcut>    </ContextMenuItem>    <ContextMenuSeparator />    <ContextMenuItem variant="destructive">      <Trash2Icon />      Move to trash    </ContextMenuItem>  </ContextMenuContent></ContextMenu>

Guidance

Use it when

  • Use on dense surfaces where right click is expected: file lists, tables, canvases, editors.
  • Mirror the actions from the object's visible menu button so mouse users find them in both places.

Avoid

  • Being the only way to reach an action. Touch and keyboard users may never open it.
  • Menus on plain text or links, where the browser menu is more useful.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Give every item a verb or a destination as its label. Put the icon first, then the label, then ContextMenuShortcut.
  • Use variant="destructive" on the item that deletes or signs out, and put it last, after a separator.
  • Group related items with ContextMenuGroup and a ContextMenuLabel in sentence case. Labels must be inside a group.
  • Icons are 16px and muted automatically. Do not add size or color classes to them.
  • Wrap the target area in ContextMenuTrigger. It renders a div, so pass layout classes to it directly.
  • Every action in a context menu must also be reachable from a visible button or a keyboard shortcut.

API

ContextMenuItem

PropTypeDefaultDescription
variant"default" | "destructive""default"destructive colors the item and its hover state.
insetbooleanfalseIndents the label to line up with items that have icons.

ContextMenuContent

PropTypeDefaultDescription
alignOffset / sideOffsetnumber4 / 0Offset from the pointer.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add context-menu# or, with the registry in components.jsonnpx shadcn@latest add @prodular/context-menu