Skip to content
← Inventory

ContextMenu

Menu of actions or options, opened by right-clicking (or long-pressing) its trigger surface. Supports nested submenus, checkbox/radio items, separators, and keyboard shortcuts. Open state is uncontrolled by default; pass onOpenChange to observe it.

Usage

import { ContextMenu, contextMenuAnatomy, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger } from "@desk/ui/components/context-menu";

Best practices

  • Use ContextMenu for a right-click / long-press menu on a surface; a menu opened by clicking a button or trigger is a DropdownMenu.

  • Wrap the target region in ContextMenuTrigger so the whole surface is right-clickable; use ContextMenuCheckboxItem / ContextMenuRadioGroup for stateful rows.

Props

ContextMenuCheckboxItem

PropTypeDefaultDescription
childrenstring | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>

Text label. Use icon prop for icons, not children. When using asChild, pass a single React element.

ContextMenuContent

PropTypeDefaultDescription
size"base" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl"
itemRadius"rounded" | "square" | "full"

Border radius for menu items. When "full", items become pill-shaped.

surfaceMenuSurface

Surface density. Compact maps to the 16px-radius, 4px-padding menu surface.

contentWidthMenuContentWidth

Named content widths from the design system.

overflowMenuOverflow

Outer content overflow behavior. Use hidden when a child owns scrolling.

ContextMenuItem

PropTypeDefaultDescription
insetboolean
tone"neutral" | "danger"
avatarReact.ReactNode
dotboolean | "neutral" | "brand" | "danger" | "warning" | "success" | "info"

Dot indicator at the start (takes precedence over icon): true for a neutral dot, or a {@link Tone} to tint it.

iconLucideIcon | React.ComponentType<React.SVGProps<SVGSVGElement>>
suffixIconLucideIcon | React.ComponentType<React.SVGProps<SVGSVGElement>>
kbdstring[]
suffixReact.ReactNode
activeboolean

Whether the item is in an active/selected state

activeIndicator"none" | "dot" | "check"

Visual indicator for active state. "dot" shows grey dot normally, green when active. "check" shows green checkmark only when active.

childrenstring | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>

Text label. Use icon prop for icons, not children. When using asChild, pass a single React element.

ContextMenuLabel

PropTypeDefaultDescription
insetboolean

ContextMenuRadioItem

PropTypeDefaultDescription
childrenstring | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>

Text label. Use icon prop for icons, not children. When using asChild, pass a single React element.

ContextMenuSeparator

PropTypeDefaultDescription
spacingContextMenuSeparatorSpacing

ContextMenuSubContent

PropTypeDefaultDescription
classNamestring
size"base" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl"
childrenReactNode

ContextMenuSubTrigger

PropTypeDefaultDescription
insetboolean
iconLucideIcon | React.ComponentType<React.SVGProps<SVGSVGElement>>
childrenstring | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>

Text label. Use icon prop for icons, not children. When using asChild, pass a single React element.

Also exports

  • componentContextMenu
  • constcontextMenuAnatomy
  • componentContextMenuGroup
  • componentContextMenuPortal
  • componentContextMenuRadioGroup
  • componentContextMenuShortcut
  • componentContextMenuSub
  • componentContextMenuTrigger

Anatomy

ContextMenu

context-menu

Context menu triggered by right-click on a surface

ContextMenuTrigger

context-menu-trigger

Surface that opens menu on right-click

ContextMenuContent

context-menu-content

Menu content container

ContextMenuItem

context-menu-item

Menu item

ContextMenuCheckboxItem

context-menu-checkbox-item

Toggleable item

ContextMenuRadioGroup

context-menu-radio-group

Exclusive selection group

ContextMenuRadioItem

context-menu-radio-item

Radio option

ContextMenuLabel

context-menu-label

Section label

ContextMenuSeparator

context-menu-separator

Visual divider

ContextMenuSub

context-menu-sub

Nested submenu

ContextMenuSubTrigger

context-menu-sub-trigger

Opens nested menu

ContextMenuSubContent

context-menu-sub-content

Nested menu container

ContextMenuShortcut

context-menu-shortcut

Keyboard shortcut

Composition

Builds on

Icon, MenuItem