Context Menu
A context menu component that appears on right-click. Built on Base UI ContextMenu primitive with the same item API as Menu.Compound Components
ContextMenu.Root
The root container that manages context menu state.Controlled open state. When provided, the menu becomes controlled.
Uncontrolled default open state.
Callback fired when the open state changes.
ContextMenu.Trigger
The element that triggers the context menu on right-click.Additional CSS classes to apply.
Merge props onto the child element instead of rendering a div.
ContextMenu.Portal
Portals the menu content to the end of the document body.Whether to keep the menu mounted in the DOM when closed.
The container element to portal into. Defaults to
document.body.ContextMenu.Positioner
Positions the menu at the cursor position.The distance in pixels from the cursor.
collisionPadding
number | { top?: number; right?: number; bottom?: number; left?: number }
default:"8"
The padding in pixels from the viewport edges.
ContextMenu.Popup
The context menu popup container with list styles.Additional CSS classes to apply. Default: Surface overlay background with shadow.
- Min-width: 220px
- Max-width: 400px
- Max-height: 320px
- Vertical scrolling when content overflows
ContextMenu.Arrow
Optional arrow pointing to the trigger position.Additional CSS classes to apply. Default:
"fill-surface-overlay"MenuItem
A clickable context menu item. Same component as Menu.Callback fired when the item is selected.
Whether the item is disabled.
Whether to close the menu when this item is selected.
Additional CSS classes to apply.
MenuPrefix
Leading content for a menu item (icon, avatar, etc.).Additional CSS classes to apply.
MenuSuffix
Trailing content for a menu item (shortcut, badge, etc.).Additional CSS classes to apply.
MenuSeparator
Visual separator between menu sections.Additional CSS classes to apply.
MenuGroup
Groups related menu items.Additional CSS classes to apply.
MenuGroupLabel
Label for a menu group.Additional CSS classes to apply. Default: Small subtle text with padding.
MenuEmpty
Empty state message when menu has no items.Additional CSS classes to apply.
ContextMenu.RadioGroup
Groups radio items with single selection.The currently selected value.
Callback fired when the selection changes.
ContextMenu.RadioItem
A radio menu item with indicator.The value of this radio item.
Whether the item is disabled.
Additional CSS classes to apply.
ContextMenu.CheckboxItem
A checkbox menu item with indicator.The checked state.
Callback fired when the checked state changes.
Whether the item is disabled.
Additional CSS classes to apply.
ContextMenu.SubmenuRoot
Root container for a submenu.Controlled open state.
Uncontrolled default open state.
Callback fired when the submenu open state changes.
ContextMenu.SubmenuTrigger
Trigger for opening a submenu.Additional CSS classes to apply.
Usage
With Checkbox Items
Submenu
Types
Accessibility
- Opens on right-click or Shift+F10
- Arrow keys navigate between items
- Enter or Space selects an item
- Escape closes the menu
- Focus is trapped within the menu when open