Skip to content
GitHub (opens in a new tab)

ContextMenu

Actions for one target, opened with a right-click or Shift+F10.

stableMoleculecontracts/contextmenu.json

Preview

ContextMenu

Actions for one target. Right-click or press Shift+F10. Arrow keys move, Enter chooses, Escape closes.

Master

A visible button that opens actions is DropdownMenu, not this.

Right-click this record. Last action: None.

Usage

Wrap the target. Disabled items are skipped. A danger item is the destructive one.

Do's

  • Actions that belong to a row, card, or canvas, not a visible button
  • The person already knows the target they are acting on

Don'ts

<ContextMenu items={actions} onSelect={run}>{record}</ContextMenu>

When to use

  • Actions that belong to a row, card, or canvas, not a visible button
  • The person already knows the target they are acting on

When not to use

  • Actions from a visible button — use DropdownMenu
  • Navigation — use SideNav (product), DocsNav (docs/catalog) or links
  • A single obvious action — use Button

What an agent reads

import { ContextMenu } from "agentic-ds-kit";
must
  • Escape closes only this panel, not a parent Modal, Drawer or AlertDialog
  • Right-click or Shift+F10 opens the menu at the pointer or the target
  • Menu is role=menu. Each action is role=menuitem
  • Arrow keys, Home, and End move. Enter and Space choose. Escape closes
  • Disabled items are aria-disabled and are skipped
  • Choosing an item closes the menu
  • Highlight: the fill is one decorative layer (aria-hidden) that glides to the active row on hover and arrow keys (clip-path only, --motion-expand-*); it lands in place on first show, after the pointer leaves and on resize or scroll, and jumps with no slide under prefers-reduced-motion. Roles, tabIndex and focus order are unchanged and the focus ring stays on the row
defaults
  • ariaLabel Actions
stops if
  • Do not use ContextMenu when the actions should be visible — use DropdownMenu or Button
  • Do not put navigation links in the menu
  • Do not use raw hex

From contracts/contextmenu.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
itemsarrayYes—Each item is { id, label, disabled?, danger?, shortcut? }.
onSelectfunctionNo—(id: string) => void
childrenslotYes—The surface that opens the menu.
ariaLabelstringNoActions—
  • Component
    →

    DropdownMenu

    Actions or value menu from a button, field, or nav trigger.

  • Component
    →

    SideNav

    Product side nav: brand header, icon items, optional badges, closeable; variant single (one column that closes to an icon rail) or rail-subnav (a fixed icon rail plus a SideNav.SubNav column with the picked parent's rows).

  • Component
    →

    DocsNav

    Docs and catalog sidebar only: title, grouped text-only links, optional decorative icons and muted counts on group and subgroup headers only, an active page pill and optional footer links.

  • Component
    →

    Button

    Clickable action control with appearance × mode (plus an optional flat set) and a fixed set of sizes.