Skip to content

ContextMenu

ContextMenu(__namedParameters): ReactElement<{ ref: RefObject<OverlayRootWidget | null>; }, string | JSXElementConstructor<any>> | null

Defined in: react/components/overlay/context-menu.tsx:56

A floating action menu pinned to a point — the classic right-click / overflow menu. It floats on a modal overlay layer that grabs focus (so ↑/↓/Enter drive it), positions its top-left at (ContextMenuProps.x, y) clamped fully on-screen, and dismisses on selection, Esc, or an outside click.

Drive open/x/y yourself or, more simply, with useContextMenu:

const menu = useContextMenu();
<Box onMouseDown={(ev) => ev.button === "right" && menu.openAt(ev.x, ev.y)}></Box>
<ContextMenu
{...menu.props}
items={[
{ label: "Copy", shortcut: "Ctrl+C" },
{ separator: true },
{ label: "Delete", danger: true },
]}
onSelect={(item) => run(item)}
/>

ContextMenuProps

ReactElement<{ ref: RefObject<OverlayRootWidget | null>; }, string | JSXElementConstructor<any>> | null