Context Menu
Displays a menu of actions triggered by a right-click (or long-press on touch devices).
Installation
pnpm add @notion-kit/uiAnatomy
<ContextMenu>
<ContextMenuTrigger />
<ContextMenuContent>
<ContextMenuGroup>
<ContextMenuLabel />
<ContextMenuItem />
<ContextMenuItem />
</ContextMenuGroup>
<ContextMenuSeparator />
<ContextMenuSub>
<ContextMenuSubTrigger />
<ContextMenuSubContent>
<ContextMenuGroup>
<ContextMenuItem />
</ContextMenuGroup>
</ContextMenuSubContent>
</ContextMenuSub>
<ContextMenuCheckboxItem />
</ContextMenuContent>
</ContextMenu>Examples
Default
A context menu with groups, shortcuts, submenus, checkbox items, and a destructive action.
API Reference
ContextMenu
The root component. Wraps the trigger and content.
ContextMenuTrigger
The area that activates the context menu on right-click or long-press.
| Prop | Type | Default | Description |
|---|---|---|---|
render | React.ReactElement | (props, state) => React.ReactElement | - | Renders a custom trigger element and merges trigger props onto it. |
ContextMenuContent
The popover panel that appears at the pointer position.
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "right" | "bottom" | "left" | - | Forces the panel to a specific side. |
ContextMenuItem
A single actionable item in the menu. Extends the shared MenuItem props.
| Prop | Type | Default | Description |
|---|---|---|---|
label | React.ReactNode | - | The label text or content of the item. |
icon | React.ReactNode | - | An optional leading icon. |
desc | string | - | An optional description below the label. |
variant | "default" | "secondary" | "sidebar" | "warning" | "error" | "default" | The visual style of the item. |
disabled | boolean | - | Whether the item is disabled. |
onClick | React.MouseEventHandler<HTMLElement> | - | Handler called when the item is clicked. |
ContextMenuCheckboxItem
A menu item that can be toggled on and off. Extends ContextMenuItem props.
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | - | Whether the item is checked. |
onCheckedChange | (checked: boolean) => void | - | Handler called when the checked state changes. |
ContextMenuLabel
A non-interactive label used to title a group of items.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | The group label text. |
ContextMenuSeparator
A visual divider between groups of items.
ContextMenuShortcut
Displays a keyboard shortcut hint aligned to the right of an item.
ContextMenuGroup
Groups related menu items together with consistent spacing.
ContextMenuSub
Wraps a sub-menu trigger and its content.
ContextMenuSubTrigger
A menu item that opens a nested sub-menu. Accepts the same props as ContextMenuItem.
ContextMenuSubContent
The popover panel for a sub-menu.