Components

Context Menu

A menu of actions revealed by right-clicking (or long-pressing) a target region, built on Radix with full keyboard navigation and nested submenus.

Basic usage

Right-click the dashed box to open the menu.

Right-click here

Checkboxes, radios & submenus

Compose ContextMenuCheckboxItem, ContextMenuRadioGroup, and ContextMenuSub for richer menus. These previews stay uncontrolled via defaultChecked and defaultValue.

Right-click here

Props

PropTypeDefaultDescription
ContextMenuRootWraps the trigger and content. Manages open state; uncontrolled by default.
ContextMenuTriggerReactNodeThe region that opens the menu on right-click (or long-press on touch). Pass className to style the box.
ContextMenuContentReactNodeThe floating surface, rendered in a portal. Holds the menu items.
ContextMenuItemReactNodeA selectable action. Accepts variant and inset.
ContextMenuItem.variant'default' | 'destructive''default'Use destructive to render the item in the danger color.
ContextMenuItem.insetbooleanfalseAdds left padding to align with items that have a leading icon or indicator.
ContextMenuCheckboxItemReactNodeToggleable item with a check indicator. Controlled via checked / defaultChecked.
ContextMenuRadioGroupReactNodeGroups radio items; value / defaultValue selects the active one.
ContextMenuRadioItemReactNodeA single-choice item; requires a unique value prop.
ContextMenuSubReactNodeWraps a nested submenu (SubTrigger + SubContent).
ContextMenuLabelReactNodeA non-interactive group heading. Accepts inset.
ContextMenuSeparatorReactNodeA horizontal divider between groups of items.
ContextMenuShortcutReactNodeRight-aligned text for a keyboard shortcut hint.

Accessibility

  • The menu opens on the platform context-menu gesture — right-click on pointer devices and long-press on touch.
  • Once open, focus is trapped inside the menu and arrow keys move between items, with type-ahead to jump by first letter.
  • Enter or Space activate the focused item; Esc closes the menu and restores focus to the trigger.
  • Items carry the correct menuitem, menuitemcheckbox, and menuitemradio roles; disabled items are skipped during keyboard navigation.