Skip to content

Context Menu

Right-click menu anchored at the pointer. Portal-mounted, viewport-clamped, keyboard-navigable. Same item shape as Dropdown Menu.

Overlays & Feedback@sisyphos-ui/context-menuView on npmView as Markdown

Preview

tsx
Right-click anywhere in this area

Installation

Install the individual package:

$ pnpm add @sisyphos-ui/context-menu @sisyphos-ui/core

Or use the umbrella package that bundles everything:

$ pnpm add @sisyphos-ui/ui

Usage

Import the component styles and the component itself:

snippet.tsxtsx
import "@sisyphos-ui/context-menu/styles.css";
import { ContextMenu } from "@sisyphos-ui/context-menu";

Labeled sections

`type: "label"` renders a non-interactive section header. Perfect for grouping destructive actions.

tsx
Project · Q2 launch.md

Per-row table menu

Wrap each `<tr>` in its own `<ContextMenu>` so each row gets a menu scoped to its data.

tsx
NameRole
Ada LovelaceAdmin
Alan TuringMember
Grace HopperMember

Right-click any row.

API

PropTypeDefaultDescription
items*ContextMenuItem[]Actions, separators, and labels rendered inside the menu.
children*ReactElementThe trigger — any element that accepts `onContextMenu`.
marginnumber8Viewport margin so the menu never sits flush against an edge.
disabledbooleanfalseWhen true, right-click is a no-op.
emptyStateReactNodeRendered when `items` is empty.
onOpenChange(open: boolean) => voidFires when the menu opens or closes.

The full API including refs, ARIA attributes, and HTML passthroughs lives in the package README.

Accessibility

Adheres to the Menu WAI-ARIA design pattern.

Keyboard interactions

KeyAction
ArrowDownthenArrowUpMove between items.
HomethenEndJump to first / last item.
EnterthenSpaceActivate the focused item.
EscClose the menu; focus returns to the trigger.
TabClose the menu.
Was this page helpful?