About the shadcn/ui Context Menu Component
The Context Menu component is part of shadcn/ui — a collection of accessible, copy-paste React components built with Radix UI and Tailwind CSS. Install it with `npx shadcn@latest add context-menu` and copy it directly into your project.
Context Menu Component — Frequently Asked Questions
How do I trigger a shadcn ContextMenu on an image or card?
Wrap the element in `<ContextMenuTrigger>`: `<ContextMenuTrigger><img src="..." /></ContextMenuTrigger>`. Right-clicking the image shows the context menu.
How do I disable a ContextMenu item based on state?
Add the `disabled` prop: `<ContextMenuItem disabled={!hasSelection}>Cut</ContextMenuItem>`. Disabled items are visible but not clickable.
How do I add icons to ContextMenu items?
Place an icon before the text inside `<ContextMenuItem>`: `<ContextMenuItem><Copy className="mr-2 h-4 w-4" />Copy</ContextMenuItem>`.