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
ContextMenufor a right-click / long-press menu on a surface; a menu opened by clicking a button or trigger is aDropdownMenu.Wrap the target region in
ContextMenuTriggerso the whole surface is right-clickable; useContextMenuCheckboxItem/ContextMenuRadioGroupfor stateful rows.
Props
ContextMenuCheckboxItem
| Prop | Type | Default | Description |
|---|---|---|---|
| children | string | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Text label. Use |
ContextMenuContent
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "base" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | ||
| itemRadius | "rounded" | "square" | "full" | Border radius for menu items. When "full", items become pill-shaped. | |
| surface | MenuSurface | Surface density. Compact maps to the 16px-radius, 4px-padding menu surface. | |
| contentWidth | MenuContentWidth | Named content widths from the design system. | |
| overflow | MenuOverflow | Outer content overflow behavior. Use hidden when a child owns scrolling. |
ContextMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | ||
| tone | "neutral" | "danger" | ||
| avatar | React.ReactNode | ||
| dot | boolean | "neutral" | "brand" | "danger" | "warning" | "success" | "info" | Dot indicator at the start (takes precedence over icon): | |
| icon | LucideIcon | React.ComponentType<React.SVGProps<SVGSVGElement>> | ||
| suffixIcon | LucideIcon | React.ComponentType<React.SVGProps<SVGSVGElement>> | ||
| kbd | string[] | ||
| suffix | React.ReactNode | ||
| active | boolean | 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. | |
| children | string | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Text label. Use |
ContextMenuLabel
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean |
ContextMenuRadioItem
| Prop | Type | Default | Description |
|---|---|---|---|
| children | string | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Text label. Use |
ContextMenuSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
| spacing | ContextMenuSeparatorSpacing |
ContextMenuSubContent
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ||
| size | "base" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | ||
| children | ReactNode |
ContextMenuSubTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | ||
| icon | LucideIcon | React.ComponentType<React.SVGProps<SVGSVGElement>> | ||
| children | string | number | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Text label. Use |
Also exports
- component
ContextMenu - const
contextMenuAnatomy - component
ContextMenuGroup - component
ContextMenuPortal - component
ContextMenuRadioGroup - component
ContextMenuShortcut - component
ContextMenuSub - component
ContextMenuTrigger
Anatomy
ContextMenu
context-menuContext menu triggered by right-click on a surface
ContextMenuTrigger
context-menu-triggerSurface that opens menu on right-click
ContextMenuContent
context-menu-contentMenu content container
ContextMenuItem
context-menu-itemMenu item
ContextMenuCheckboxItem
context-menu-checkbox-itemToggleable item
ContextMenuRadioGroup
context-menu-radio-groupExclusive selection group
ContextMenuRadioItem
context-menu-radio-itemRadio option
ContextMenuLabel
context-menu-labelSection label
ContextMenuSeparator
context-menu-separatorVisual divider
ContextMenuSub
context-menu-subNested submenu
ContextMenuSubTrigger
context-menu-sub-triggerOpens nested menu
ContextMenuSubContent
context-menu-sub-contentNested menu container
ContextMenuShortcut
context-menu-shortcutKeyboard shortcut