Context Menu

Right click context menu that opens at the cursor with menu items, including destructive items in red. Closes on selection or click outside, in React.

src/registry/ui/context-menu.tsx/r/context-menu.json

Installation#

bash
npx shadcn@latest add @minidev/context-menu

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/context-menu.json

Usage#

tsx
import { ContextMenu } from "@/components/ui/context-menu"

export function Example() {
  return <ContextMenu />
}

API reference#

ContextMenu props
PropTypeDefault
children*React.ReactNode-
items*{ id: string; label: string; destructive?: boolean; onSelect?: () => void }[]-
classNamestring-

* required

All dialog, drawer and popover components

Learn more