Right-click here, or long-press on touch
Installation
$ pnpm dlx shadcn@latest add @synccn/context-menuFirst time in this project? Connect synccn with one command.
Usage
import { ContextMenu } from "@/components/ui/context-menu";<ContextMenu items={items}>…</ContextMenu>API reference
Generated from the component's TypeScript types, so it always matches the code.
ContextMenu
Right-click (or long-press) menu. items use the same shape as DropdownMenu.
PropTypeDescription
- itemsrequired
ContextMenuItem[]Menu entries.
- children
React.ReactNodeContent to render.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
Keyboard
- EscClose the menu
Accessibility
- Opens on right-click or long-press. Offer the same actions somewhere visible too, since context menus are hard to discover.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: menu, menuitem
- Closes with Escape
- Closes when you click or tap outside
- Shows a visible focus ring for keyboard users
More overlays
DialogModal with focus trap, scroll lock and Escape to close.SheetPanel that slides in from the left, right or bottom.Dropdown MenuActions, checkboxes, labels and shortcuts with arrow-key navigation.PopoverFloating panel anchored to a trigger.TooltipLabel on hover and focus, on any side.CommandSearchable, grouped command list — the engine behind ⌘K.