--- title: Context Menu description: Displays a menu of actions triggered by a right click. base: base component: true links: doc: https://base-ui.com/react/components/context-menu api: https://base-ui.com/react/components/context-menu#api-reference --- ## Installation Command Manual ```bash npx shadcn@latest add context-menu ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx showLineNumbers import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger, } from "@/components/ui/context-menu" ``` ```tsx showLineNumbers Right click here Profile Billing Team Subscription ``` ## Examples ### Basic A simple context menu with a few actions. ### Submenu Use `ContextMenuSub` to nest secondary actions. ### Shortcuts Add `ContextMenuShortcut` to show keyboard hints. ### Groups Group related actions and separate them with dividers. ### Icons Combine icons with labels for quick scanning. ### Checkboxes Use `ContextMenuCheckboxItem` for toggles. ### Radio Use `ContextMenuRadioItem` for exclusive choices. ### Destructive Use `variant="destructive"` to style the menu item as destructive. ### Sides Control submenu placement with side and align props. ## RTL To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl). Use `side="inline-end"` to place the menu on the logical right side of the trigger. ```tsx showLineNumbers Right click here Profile Billing Team Subscription ``` ## API Reference See the [Base UI](https://base-ui.com/react/components/context-menu#api-reference) documentation for more information.