ContextMenu
A right-click (or long-press) menu that surfaces contextual actions for a target element.
Opens on the contextmenu event or platform menu key; uses role="menu" / role="menuitem"; arrow keys navigate; Esc closes and restores focus.
Variants
Section titled “Variants”With submenu
Section titled “With submenu”Nest ContextMenuSub + ContextMenuSubTrigger + ContextMenuSubContent to render hierarchical actions.
Checkbox and radio items
Section titled “Checkbox and radio items”Use ContextMenuCheckboxItem for toggles and ContextMenuRadioItem inside a ContextMenuRadioGroup for mutually-exclusive selection.
With shortcuts
Section titled “With shortcuts”ContextMenuShortcut renders kbd-style chips after the item label. They are decorative and not announced.
PropTypeDefaultDescription
container
HTMLElement|(() => HTMLElement)
—
className
string
—
Accessibility
Section titled “Accessibility”- Opens via the native
contextmenuevent (right-click, two-finger tap, long-press) or the platform menu key while the trigger has focus. ContextMenuContentcarriesrole="menu"; items exposerole="menuitem".- Arrow keys move between items;
Home/Endjump to the first / last; type-ahead also selects the first matching item. - Pressing
Esccloses the menu and returns focus to the previously focused element. ContextMenuCheckboxItemreportsrole="menuitemcheckbox";ContextMenuRadioItemreportsrole="menuitemradio".
Recipes
Section titled “Recipes”- Wrap your trigger in
asChildso the right-click handler attaches to your own element rather than an extra wrapper div. - Mirror the same item set in a toolbar or
DropdownMenuso users can rely on either surface. - Use
ContextMenuLabelto group nameable sections inside long menus. - Put destructive actions last under a
ContextMenuSeparatorso they are never the default landing item.