110k
New

Context Menu

Displays a menu of actions triggered by a right click.

Component context-menu-demo not found in registry.

Installation

pnpm dlx createui@latest add context-menu

Usage

import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuTrigger,
} from "@/components/ui/context-menu"
<ContextMenu>
  <ContextMenuTrigger>Right click here</ContextMenuTrigger>
  <ContextMenuContent>
    <ContextMenuItem>Profile</ContextMenuItem>
    <ContextMenuItem>Billing</ContextMenuItem>
    <ContextMenuItem>Team</ContextMenuItem>
    <ContextMenuItem>Subscription</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

Examples

Basic

A simple context menu with a few actions.

Component context-menu-basic not found in registry.

Use ContextMenuSub to nest secondary actions.

Component context-menu-submenu not found in registry.

Shortcuts

Add ContextMenuShortcut to show keyboard hints.

Component context-menu-shortcuts not found in registry.

Groups

Group related actions and separate them with dividers.

Component context-menu-groups not found in registry.

Icons

Combine icons with labels for quick scanning.

Component context-menu-icons not found in registry.

Checkboxes

Use ContextMenuCheckboxItem for toggles.

Component context-menu-checkboxes not found in registry.

Radio

Use ContextMenuRadioItem for exclusive choices.

Component context-menu-radio not found in registry.

Destructive

Use variant="destructive" to style the menu item as destructive.

Component context-menu-destructive not found in registry.

Sides

Control submenu placement with side and align props.

Component context-menu-sides not found in registry.

API Reference

See the Radix UI documentation for more information.