Context Menu

A right-click menu built by composition. Wrap a ContextMenuTrigger area and a ContextMenuContent list inside ContextMenu. The menu anchors to the cursor position, closes on dismiss, and supports full keyboard navigation. Item selection is handled per-item via onSelect.

Basic

Right-click the area below to open the menu. Items run their onSelect callback and close the menu; a ContextMenuSeparator divides routine actions from the destructive danger item, and disabled items are skipped by keyboard navigation.

Right-click anywhere in this area

Labels, groups & shortcuts

Use ContextMenuLabel for section captions, ContextMenuGroup to cluster related items, and ContextMenuShortcut to right-align a keyboard hint inside an item.

Right-click for grouped actions

Props

ContextMenuItem

PropTypeDefaultDescription
onSelect() => voidCalled when the item is chosen; the menu closes afterward.
dangerbooleanfalseRenders the item in the danger (destructive) tone.
variant'default' | 'destructive''default''destructive' renders the item in the danger tone.
disabledbooleanfalseDims the item and removes it from pointer and keyboard interaction.
asChildbooleanfalseRender through to a single child element instead of a wrapping div.

Sub-components

ComponentDescription
ContextMenuRoot provider. Accepts onOpenChange and composes the trigger + content.
ContextMenuTriggerThe area whose right-click opens the menu. Pass asChild to use your own element.
ContextMenuContentThe floating menu panel that holds the items.
ContextMenuItemAn actionable row. See the props table above.
ContextMenuLabelUppercase section caption; non-interactive.
ContextMenuGroupWraps related items for spacing and role="group" semantics.
ContextMenuSeparatorA horizontal divider between sections.
ContextMenuShortcutRight-aligned keyboard-hint text rendered inside an item.
ContextMenuPortalNo-op wrapper; the content portals itself, so wrapping it is optional.