Context Menu
Right-click menu that displays contextual actions for specific elements
Primitive
The context menu opens on right-click and lists actions scoped to the element under the cursor. Use it for row actions in a table, canvas or editor commands, or any desktop-style secondary menu; for a button-triggered menu, use Dropdown Menu instead.
Preview
Installation
Usage
Composition
Examples
With Submenus
Nest a ContextMenuSub to open a second menu from a trigger item.
With Separators and Shortcuts
Use ContextMenuSeparator to divide groups and ContextMenuShortcut to show key hints.
With Checkboxes and Radio Groups
Use ContextMenuCheckboxItem for toggles and ContextMenuRadioGroup for single-choice options. Both put their indicator in a reserved column on the right, so labels stay put as items toggle.
With Switch
Set indicator="switch" on ContextMenuCheckboxItem to swap the checkmark for a switch. Visual only: the item keeps its menuitemcheckbox role, the row stays the click target, and the menu stays open on toggle.
With Filter
Wrap a ContextMenuSub (or the whole ContextMenu) in ContextMenuFilter, then put a ContextMenuInput above a ContextMenuList to filter items as you type. Add p-0 to that content's className; the field and list bring their own spacing. The parts work like Dropdown Menu's.
API Reference
ContextMenuContent
ContextMenuItem
| Value | Description |
|---|---|
default | A standard menu action. |
destructive | A dangerous action such as delete or remove. |
ContextMenuLinkItem
Menu item that renders as an anchor (<a>) for navigation links. Wraps Base UI's ContextMenu.LinkItem.
ContextMenuCheckboxItem
Toggleable menu item. Wraps Base UI's ContextMenu.CheckboxItem. The indicator sits in a reserved column on the right.
ContextMenuRadioItem
Mutually exclusive menu item. Wraps Base UI's ContextMenu.RadioItem. Uses the same right-aligned checkmark as ContextMenuCheckboxItem.
ContextMenuLabel
ContextMenuGroupLabel
ContextMenuSubTrigger
ContextMenuSubContent
ContextMenuFilter
Enables filtering for the ContextMenu or ContextMenuSub it wraps. Wraps Base UI's Menu.FilterProvider, which works because ContextMenu renders a Menu root inside.
ContextMenuInput
Search field above ContextMenuList, built like DropdownMenuInput. Props are forwarded to Menu.Input.
ContextMenuList, ContextMenuEmpty, ContextMenuClear
These work like Dropdown Menu's: the list scrolls below the field in a ScrollArea (its className goes there), the empty message shows when nothing matches, and the clear button empties the query.
Additional Props
ContextMenu components inherit all props from Base UI Context Menu, including open, defaultOpen, onOpenChange, positioning options, and accessibility props.