HomeDocsComponentsBlocksChartsThemes
Introduction
  • Introduction
  • Installation
  • Themes
  • llms.txt
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar
  • Avatar Upload
  • Badge
  • Banner
  • Breadcrumb
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • File Upload
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Label
  • Menubar
  • Meter
  • Multi Select
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Password Strength
  • Phone Input
  • Popover
  • Progress
  • Progress Circle
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sortable
  • Spinner
  • Stat
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree
  • Typography
  • Video Player
  • Window Mockup
AI
  • Message Scroller
  • Message
  • Bubble
  • Marker
  • Attachment
  • Questionnaire
  • Composer
  • Reasoning
  • Tool Call
  • Approval Card
  • Citations
Blocks
  • Airtable
  • Airtable Kanban
  • ClickUp List
  • ClickUp Kanban
  • Repeatable Group
  • Command Palette
  • Sign In and Sign Up
  • Availability Scheduler
  • AI Chat
  • Action Bar
  • Notion
  • Banking
  • Lineup Builder
  • Sports Score
  • Strava
  • Sheets
  • Notices
  • Settings
  • Billing
Utilities
  • motion
  • sounds
  • scroll-fade
  • shimmer
Another UI. Built on shadcn/ui with Phosphor icons.

Context Menu

PreviousNext

Displays a menu of actions triggered by a right click.

Base UIReact AriaRadix UI
Right click hereLong press here
import {
  ContextMenu,
  ContextMenuCheckboxItem,

Installation#

pnpm dlx shadcn@latest add https://anotherui.dev/r/context-menu.json

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>

Composition#

Use the following composition to build a ContextMenu:

ContextMenu
├── ContextMenuTrigger
└── ContextMenuContent
    ├── ContextMenuGroup
    │   ├── ContextMenuLabel
    │   ├── ContextMenuItem
    │   └── ContextMenuItem
    ├── ContextMenuSeparator
    ├── ContextMenuGroup
    │   ├── ContextMenuLabel
    │   ├── ContextMenuCheckboxItem
    │   └── ContextMenuCheckboxItem
    ├── ContextMenuSeparator
    ├── ContextMenuGroup
    │   ├── ContextMenuLabel
    │   └── ContextMenuRadioGroup
    │       ├── ContextMenuRadioItem
    │       └── ContextMenuRadioItem
    └── ContextMenuSub
        ├── ContextMenuSubTrigger
        └── ContextMenuSubContent
            └── ContextMenuGroup
                ├── ContextMenuItem
                └── ContextMenuItem

Basic#

A simple context menu with a few actions.

Right click hereLong press here
import {
  ContextMenu,
  ContextMenuContent,

Submenu#

Use ContextMenuSub to nest secondary actions.

Right click hereLong press here
import {
  ContextMenu,
  ContextMenuContent,

Shortcuts#

Add ContextMenuShortcut to show keyboard hints.

Right click hereLong press here
import {
  ContextMenu,
  ContextMenuContent,

Groups#

Group related actions and separate them with dividers.

Right click hereLong press here
import {
  ContextMenu,
  ContextMenuContent,

Icons#

Combine icons with labels for quick scanning.

Right click hereLong press here
import { ClipboardIcon, CopyIcon, ScissorsIcon, TrashIcon } from "@phosphor-icons/react"

import {

Checkboxes#

Use ContextMenuCheckboxItem for toggles.

Right click hereLong press here
import {
  ContextMenu,
  ContextMenuCheckboxItem,

Radio#

Use ContextMenuRadioItem for exclusive choices.

Right click hereLong press here
"use client"

import * as React from "react"

Destructive#

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

Right click hereLong press here
import { ArchiveIcon, PencilIcon, ShareIcon, TrashIcon } from "@phosphor-icons/react"

import {

Sides#

Control submenu placement with side and align props.

Right click (top)Long press (top)
Right click (right)Long press (right)
Right click (bottom)Long press (bottom)
Right click (left)Long press (left)
import {
  ContextMenu,
  ContextMenuContent,

RTL#

To enable RTL support, see the RTL configuration guide.

انقر بزر الماوس الأيمن هنااضغط مطولاً هنا
"use client"

import * as React from "react"

Use side="inline-end" to place the menu on the logical right side of the trigger.

<ContextMenu>
  <ContextMenuTrigger>Right click here</ContextMenuTrigger>
  <ContextMenuContent side="inline-end">
    <ContextMenuItem>Profile</ContextMenuItem>
    <ContextMenuItem>Billing</ContextMenuItem>
    <ContextMenuItem>Team</ContextMenuItem>
    <ContextMenuItem>Subscription</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

API Reference#

See the Base UI documentation for more information.

ComposerCopy Button

On This Page

InstallationUsageCompositionBasicSubmenuShortcutsGroupsIconsCheckboxesRadioDestructiveSidesRTLAPI Reference