ContextMenu

Context menus that open at the pointer, sharing the same menu logic and parts as DropdownMenu: checkbox, radio, groups, submenus and full keyboard navigation.

Props

PropTypeDefaultDescription
openboolean—Controlled open state
defaultOpenbooleanfalseInitial open state when uncontrolled
onOpenChange(open: boolean) => void—Called whenever the open state changes
placement'top' | 'bottom' | 'left' | 'right''bottom'Preferred side relative to the pointer: top / bottom / left / right
align'start' | 'center' | 'end''start'Cross-axis alignment: start / center / end
offsetnumber2Distance from the pointer
ContextMenu.TriggerHTMLAttributes—The right-click area; asChild merges onto the only child
ContextMenu.ContentHTMLAttributes—The menu container, role="menu"
ContextMenu.ItemButtonHTMLAttributes—A menu item, role="menuitem", closes the menu on select
onSelect(event) => void—Called on select; call event.preventDefault() to keep the menu open
ContextMenu.CheckboxItemButtonHTMLAttributes—A checkable item, stays open after toggling
ContextMenu.RadioGroupHTMLAttributes—A group of radio items
ContextMenu.RadioItemButtonHTMLAttributes—A radio item, stays open after selecting
ContextMenu.Subobject—Submenu root
ContextMenu.SubTriggerButtonHTMLAttributes—The submenu trigger, opens on hover or arrow keys
ContextMenu.SubContentHTMLAttributes—The submenu container, opens to the right by default
ContextMenu.GroupHTMLAttributes—A group container
ContextMenu.LabelHTMLAttributes—A group label
ContextMenu.SeparatorHTMLAttributes—A divider between groups
ContextMenu.ShortcutHTMLAttributes—A trailing shortcut hint