
Right-click context menu with items, checkboxes, radio groups, and submenus.
npx shadcn@latest add https://ui.edbn.me/api/analytics/registry/context-menu.jsonCreates a context menu activated by right click or long press. Doesn't render its own HTML element.
defaultOpenbooleanfalseInitial open state
openbooleanControlled open state
onOpenChange(open, eventDetails) => voidCalled when the menu opens or closes
onOpenChangeComplete(open: boolean) => voidCalled after close animations complete
highlightItemOnHoverbooleantrueHighlight items when the pointer moves over them
actionsRefRefObject<ContextMenu.Root.Actions | null>Imperative close and unmount actions
closeParentOnEscbooleanfalseClose the parent menu when Escape is pressed in a submenu
defaultTriggerIdstring | nullInitial trigger id for an initially open menu
handleMenu.Handle<unknown>Handle for associated menu triggers
loopFocusbooleantrueLoop keyboard focus through menu items
triggerIdstring | nullControlled trigger id for an open menu
disabledbooleanfalseIgnore user interaction
orientation'horizontal' | 'vertical''vertical'Roving-focus orientation
childrenReactNode | PayloadChildRenderFunction<unknown>Menu content; inherited Base UI render functions receive an unknown payload
An area that opens the menu on right click or long press. Renders a div element.
classNamestring | functionCSS class name or state-based class function
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-popup-open | Present when the corresponding context menu is open |
| data-pressed | Present while the trigger is pressed |
Moves the popup to a different part of the DOM. Renders a div element.
containerHTMLElement | ShadowRoot | RefObject | nullPortal container
keepMountedbooleanfalseKeep the portal mounted while hidden
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
An overlay displayed beneath the context menu popup. Renders a div element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when menu is open |
| data-closed | Present when menu is closed |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
Positions the popup against the trigger point. Renders a div element.
side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end''bottom'Preferred side relative to the anchor
sideOffsetnumber | OffsetFunction0Distance from the anchor
align'start' | 'center' | 'end''center'Alignment relative to the side
alignOffsetnumber | OffsetFunction0Offset along the alignment axis
arrowPaddingnumber5Minimum distance between arrow and popup edge
anchorElement | VirtualElement | RefObject | function | nullCustom anchor element
collisionAvoidanceCollisionAvoidanceHow to flip or shift when the popup would overflow
collisionBoundaryBoundary'clipping-ancestors'Boundary used for collision detection
collisionPaddingPadding5Space to preserve from the collision boundary
disableAnchorTrackingbooleanfalseStop tracking anchor layout shifts
stickybooleanfalseKeep popup visible after the anchor scrolls out of view
positionMethod'absolute' | 'fixed''absolute'CSS positioning strategy
classNamestring | functionCSS class name or state-based class function
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when popup is open |
| data-closed | Present when popup is closed |
| data-anchor-hidden | Present when the anchor is hidden |
| data-align | Alignment relative to side |
| data-side | Side popup is positioned on |
| Variable | Description |
|---|---|
| --anchor-height | Anchor height |
| --anchor-width | Anchor width |
| --available-height | Available height |
| --available-width | Available width |
| --transform-origin | Origin used for anchored animations |
A container for the context menu items. Renders a div element.
finalFocusboolean | RefObject | functionElement or behavior to focus when the menu closes
childrenReactNodeMenu content
classNamestring | functionCSS class name or state-based class function
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when menu is open |
| data-closed | Present when menu is closed |
| data-align | Alignment relative to side |
| data-instant | Present when animations should be skipped |
| data-side | Side popup is positioned on |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
| Variable | Description |
|---|---|
| --popup-height | Current popup height |
| --popup-width | Current popup width |
Displays an arrow element positioned against the menu anchor. Renders a div element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when popup is open |
| data-closed | Present when popup is closed |
| data-uncentered | Present when arrow cannot be centered |
| data-align | Alignment relative to side |
| data-side | Side popup is positioned on |
An individual interactive item in the menu. Renders a div element.
labelstringText label for keyboard typeahead
onClickfunctionClick handler
closeOnClickbooleantrueClose menu when clicked
nativeButtonbooleanfalseWhether a custom render target is a native button
disabledbooleanfalseIgnore user interaction
insetbooleanfalseEDBN wrapper prop that aligns text with indicator rows
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-highlighted | Present when item is highlighted |
| data-disabled | Present when item is disabled |
A link item used to navigate to another page or section. Renders an anchor element.
labelstringText label for keyboard typeahead
closeOnClickbooleanfalseClose menu when clicked
insetbooleanfalseEDBN wrapper prop that aligns text with indicator rows
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-highlighted | Present when link is highlighted |
A separator element accessible to screen readers. Renders a div element.
orientation'horizontal' | 'vertical''horizontal'Separator orientation
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
Groups related menu items with the corresponding label. Renders a div element.
childrenReactNodeGroup contents
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
An accessible label associated with its parent group. Renders a div element.
insetbooleanfalseEDBN wrapper prop that aligns text with indicator rows
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
Groups all parts of a submenu. Doesn't render its own HTML element.
defaultOpenbooleanfalseInitial open state
openbooleanControlled open state
onOpenChange(open, eventDetails) => voidCalled when the submenu opens or closes
highlightItemOnHoverbooleantrueHighlight items when hovered
actionsRefRefObject<Menu.Root.Actions | null>Imperative close and unmount actions
closeParentOnEscbooleanfalseClose the parent menu on Escape
defaultTriggerIdstring | nullInitial trigger id
handleMenu.Handle<unknown>Handle for associated triggers
loopFocusbooleantrueLoop keyboard focus
onOpenChangeComplete(open: boolean) => voidCalled after close animations complete
triggerIdstring | nullControlled trigger id
disabledbooleanfalseIgnore user interaction
orientation'horizontal' | 'vertical''vertical'Roving-focus orientation
childrenReactNode | PayloadChildRenderFunction<unknown>Submenu content; inherited Base UI render functions receive an unknown payload
A menu item that opens a submenu. Renders a div element.
labelstringText label for keyboard typeahead
onClickfunctionClick handler
nativeButtonbooleanfalseWhether a custom render target is a native button
disabledbooleanfalseIgnore user interaction
openOnHoverbooleanAlso open when hovered
delaynumber100Hover-open delay in milliseconds
closeDelaynumber0Hover-close delay in milliseconds
insetbooleanfalseEDBN wrapper prop that aligns text with indicator rows
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-popup-open | Present when submenu is open |
| data-highlighted | Present when highlighted |
| data-disabled | Present when disabled |
Groups related radio items. Renders a div element.
defaultValueanyInitial selected value
valueanyControlled selected value
onValueChange(value, eventDetails) => voidCalled when selected value changes
disabledbooleanfalseIgnore user interaction
childrenReactNodeRadio item contents
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
A menu item that works like a radio button in a group. Renders a div element.
valueanyrequiredValue selected in the radio group
labelstringText label for keyboard typeahead
onClickfunctionClick handler
closeOnClickbooleanfalseClose menu when clicked
nativeButtonbooleanfalseWhether a custom render target is a native button
disabledbooleanfalseIgnore user interaction
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-checked | Present when selected |
| data-unchecked | Present when not selected |
| data-highlighted | Present when highlighted |
| data-disabled | Present when disabled |
Indicates whether the radio item is selected. Renders a span element.
keepMountedbooleanfalseKeep the indicator mounted when inactive
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-checked | Present when selected |
| data-unchecked | Present when not selected |
| data-disabled | Present when disabled |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
A menu item that toggles a setting on or off. Renders a div element.
labelstringText label for keyboard typeahead
defaultCheckedbooleanfalseInitial checked state
checkedbooleanControlled checked state
onCheckedChange(checked, eventDetails) => voidCalled when checked state changes
onClickfunctionClick handler
closeOnClickbooleanfalseClose menu when clicked
nativeButtonbooleanfalseWhether a custom render target is a native button
disabledbooleanfalseIgnore user interaction
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-checked | Present when checked |
| data-unchecked | Present when not checked |
| data-highlighted | Present when highlighted |
| data-disabled | Present when disabled |
Indicates whether the checkbox item is checked. Renders a span element.
keepMountedbooleanfalseKeep the indicator mounted when unchecked
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-checked | Present when checked |
| data-unchecked | Present when not checked |
| data-disabled | Present when disabled |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |