Skip to Content
ComponentsContextMenu

ContextMenu

ContextMenu manages right-click menu coordinates and renders menu content in a portal.

Props

ExportKey propsDescription
ContextMenucontainerProvider that stores open state and optional boundary element.
ContextMenuTriggerdisabled, onlyDirectTarget, childrenOpens the surrounding menu from trigger content. Child contextmenu handlers can prevent opening.
ContextMenuContentcloseOnItemClick, div propsPortal layer clamped to the viewport or container.
useContextMenu-Programmatic access to openAt and close.

Examples

Right-click menu

Right click this field

Adaptive edge placement

Top-left corner
Top-right corner
Center area
Bottom-left corner
Bottom-right corner
Right-click any target to see adaptive placement.

ARIA

Pair ContextMenuContent with semantic Menu and MenuItem children. Opening the layer moves focus into the menu and closing restores focus to the previously focused element. Escape, outside pointer, scroll, and resize dismiss the layer.

Keyboard

When opened with Menu children, focus starts on the first enabled menu item. Arrow keys, Home, End, typeahead, Enter, and Space follow the Menu keyboard model. Escape closes the layer.

SSR

ContextMenuContent renders only after the menu opens on the client. The trigger child should be stable during hydration.

Last updated on