Capítulo 15 de 43
A menu that appears at the pointer position on right-click (or long-press on touch), supporting submenus, checkable items, radio groups, and full collision-aware positioning — the desktop-context-menu counterpart to DropdownMenu.
Root → Trigger (wraps the right-clickable target) → Portal → Content → Item / Group (+ Label) / CheckboxItem (+ ItemIndicator) / RadioGroup → RadioItem (+ ItemIndicator) / Sub → SubTrigger + Portal → SubContent / Separator.modal (default true): controls whether outside pointer/focus interactions are blocked while open.avoidCollisions, collisionBoundary, collisionPadding, sticky on Content — same positioning engine shared by Popover/DropdownMenu/Select/HoverCard.--radix-context-menu-content-transform-origin: exposes the computed transform origin so open/close animations can scale from the correct corner.<ContextMenu.Root>
<ContextMenu.Trigger>Right-click here</ContextMenu.Trigger>
<ContextMenu.Portal>
<ContextMenu.Content>
<ContextMenu.Item>Item 1</ContextMenu.Item>
<ContextMenu.Sub>
<ContextMenu.SubTrigger>More…</ContextMenu.SubTrigger>
<ContextMenu.Portal>
<ContextMenu.SubContent>
<ContextMenu.Item>Sub item</ContextMenu.Item>
</ContextMenu.SubContent>
</ContextMenu.Portal>
</ContextMenu.Sub>
</ContextMenu.Content>
</ContextMenu.Portal>
</ContextMenu.Root>
Sub/SubTrigger/SubContent) inside the top-level menu content.| Part | Notable props |
|---|---|
Content | loop, alignOffset, avoidCollisions, collisionBoundary, collisionPadding, sticky, hideWhenDetached |
Item | disabled, onSelect, textValue (for typeahead when content isn't plain text) |
CheckboxItem | checked/onCheckedChange (supports "indeterminate") |
RadioItem | value |
SubTrigger | disabled, textValue |
textValue when the item's visible content isn't a plain string.Sub) open/close with ArrowRight/ArrowLeft depending on reading direction (dir on Root), not just click/hover.modal={true} (the default) blocks outside interaction while open — set modal={false} if the menu should coexist with interaction elsewhere on the page.Content.