Skip to Content
ComponentsOverlayContext Menu

Context Menu

An overlay component that reveals a targeted list of actions when triggered by a right-click. 
For more information on this component configuration, visit Radix UI 

Disabled Item

Use the disabled attr or the disabled class to disable an item component.

Sizes

Use the context-menu-content-{size} class to control the component size.

Size values can include:smmd.

For more information on all available sizing utilities, visit Tailwind 

Customizing

globals.css
:root { --ex-context-menu-max-w-sm: var(--container-3xs); --ex-context-menu-max-w-md: var(--container-2xs); --ex-context-menu-radius-sm: var(--radius-sm); --ex-context-menu-radius-md: var(--radius-sm); --ex-context-menu-shadow-sm: var(--shadow-sm); --ex-context-menu-shadow-md: var(--shadow-sm); --ex-context-menu-section-gap-x-sm: calc(var(--spacing) * 1.5); --ex-context-menu-section-gap-x-md: calc(var(--spacing) * 2); --ex-context-menu-section-px-sm: calc(var(--spacing) * 1.5); --ex-context-menu-section-px-md: calc(var(--spacing) * 2); --ex-context-menu-section-py-sm: calc(var(--spacing) * 2); --ex-context-menu-section-py-md: calc(var(--spacing) * 2.5); --ex-context-menu-item-px-sm: calc(var(--spacing) * 2); --ex-context-menu-item-px-md: calc(var(--spacing) * 2); --ex-context-menu-item-py-sm: var(--spacing); --ex-context-menu-item-py-md: var(--spacing); --ex-context-menu-item-font-family: var(--font-sans); --ex-context-menu-item-font-weight: var(--font-weight-normal); --ex-context-menu-item-font-size-sm: var(--text-xs); --ex-context-menu-item-font-size-md: var(--text-sm); --ex-context-menu-item-indicator-font-size-sm: var(--text-xs); --ex-context-menu-item-indicator-font-size-md: var(--text-sm); --ex-context-menu-label-font-family: var(--font-sans); --ex-context-menu-label-font-weight: var(--font-weight-normal); --ex-context-menu-label-opacity: var(--ex-options-opacity-muted); --ex-context-menu-label-font-size-sm: var(--text-2xs); --ex-context-menu-label-font-size-md: var(--text-xs); --ex-context-menu-command-font-family: var(--font-sans); --ex-context-menu-command-font-weight: var(--font-weight-normal); --ex-context-menu-command-opacity: var(--ex-options-opacity-muted); --ex-context-menu-command-font-size-sm: var(--text-2xs); --ex-context-menu-command-font-size-md: var(--text-xs); }

API

For more information on this component configuration, visit Radix UI 

Context Menu

PropTypeDefault
asElementTypediv
asChildbooleanfalse
modalbooleantrue
onOpenChangefunction

Context Menu Trigger

ElementSelector
ContextMenu.Trigger.ex-context-menu-trigger
PropTypeDefault
asElementTypediv
asChildbooleanfalse
disabledbooleanfalse

Context Menu Portal

PropTypeDefault
containerHTMLElementdocument.body
forceMountbooleanfalse

Context Menu Content

ElementSelector
ContextMenu.Content.ex-context-menu-content
PropTypeDefault
asElementTypediv
asChildbooleanfalse
alignOffsetnumber0
avoidCollisionsbooleantrue
forceMountbooleanfalse
hideWhenDetachedbooleanfalse
loopbooleanfalse
stickyenum of ["always", "partial"]partial
onCloseAutoFocusfunction
onFocusOutsidefunction
onInteractOutsidefunction
onPointerDownOutsidefunction

Context Menu Section

ElementSelector
ContextMenu.Section.ex-context-menu-body
PropTypeDefault
asElementTypediv
asChildbooleanfalse

Context Menu Item

ElementSelector
ContextMenu.Item.ex-context-menu-item
PropTypeDefault
asElementTypediv
asChildbooleanfalse
disabledbooleanfalse
textValuestring
onSelectfunction

Context Menu Indicator

ElementSelector
ContextMenu.ItemIndicator.ex-context-menu-item-indicator
PropTypeDefault
asElementTypediv
asChildbooleanfalse
forceMountbooleantrue

Context Menu Label

ElementSelector
ContextMenu.Label.ex-context-menu-label
PropTypeDefault
asElementTypediv
asChildbooleanfalse

Context Menu Command

ElementSelector
ContextMenu.Command.ex-context-menu-command
PropTypeDefault
asElementTypekbd
asChildbooleanfalse

Context Menu Separator

ElementSelector
ContextMenu.Separator.ex-context-menu-separator
PropTypeDefault
asElementTypediv
asChildbooleanfalse

Context Menu RadioGroup

ElementSelector
ContextMenu.RadioGroup.ex-context-menu-radio-group
PropTypeDefault
asElementTypediv
asChildbooleanfalse
valuestring
onValueChangefunction

Context Menu RadioItem

ElementSelector
ContextMenu.RadioItem.ex-context-menu-radio-item
PropTypeDefault
asElementTypediv
asChildbooleanfalse
disabledbooleanfalse
textValuestring
valuestring
onSelectfunction

Context Menu CheckboxItem

ElementSelector
ContextMenu.CheckboxItem.ex-context-menu-checkbox-item
PropTypeDefault
asElementTypediv
asChildbooleanfalse
checkedbooleanfalse
disabledbooleanfalse
textValuestring
onCheckedChangefunction
onSelectfunction

Context Sub

ElementSelector
ContextMenu.Sub.ex-context-menu-sub
PropTypeDefault
asElementTypediv
asChildbooleanfalse
defaultOpenbooleanfalse
openbooleanfalse
onOpenChangefunction

Context Sub Trigger

ElementSelector
ContextMenu.SubTrigger.ex-context-menu-sub-trigger
PropTypeDefault
asElementTypediv
asChildbooleanfalse
disabledbooleanfalse
textValuestring

Context Sub Content

ElementSelector
ContextMenu.SubContent.ex-context-menu-sub-content
PropTypeDefault
asElementTypediv
asChildbooleanfalse
alignOffsetnumber-8
avoidCollisionsbooleantrue
forceMountbooleanfalse
hideWhenDetachedbooleanfalse
loopbooleanfalse
sideOffsetnumber0
stickyenum of ["always", "partial"]partial
onFocusOutsidefunction
onInteractOutsidefunction
onPointerDownOutsidefunction
Last updated on