UIComponentsReact
A menu that opens at the pointer on a right click, or on a long press by touch.
Built on the headless Context Menu.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/context-menu.jsonIt also adds utils. The app needs its setup first: Installation.
Usage
ContextMenuTrigger is the area that opens it; ContextMenuContent holds the same items as a Dropdown Menu, with the ContextMenu prefix: ContextMenuItem, ContextMenuCheckboxItem, ContextMenuRadioGroup and ContextMenuRadioItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut and ContextMenuSub with its trigger and content. An item takes inset and variant="destructive". In Angular the template writes uiContextMenuPortal around each content. Opening at the pointer, the keyboard and focus come from the headless Context Menu.
import {
ContextMenu,
ContextMenuCheckboxItem,
ContextMenuContent,
ContextMenuGroup,
ContextMenuItem,
ContextMenuLabel,
ContextMenuPortal,
ContextMenuRadioGroup,
ContextMenuRadioItem,
ContextMenuSeparator,
ContextMenuShortcut,
ContextMenuSub,
ContextMenuSubContent,
ContextMenuSubTrigger,
ContextMenuTrigger,
} from '@/components/ui/context-menu'Examples
Default
A dashed area with items, a submenu, checkbox items and radio items.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Context Menu's API reference.