Officina UI
Components

ContextMenu

Right-click menu that opens at the cursor over a target region.

ContextMenu wraps a region and opens a role="menu" at the cursor on right-click. Pass items as a flat list of entries — each with a label and optional icon, disabled, danger, and onClick. The menu stays within the viewport and closes on Escape or an outside click. Use it for per-row or per-element actions where a right-click is the natural gesture.

Example

Preview
Right click here
import { ContextMenu } from '@officina/ui';

<ContextMenu
  items={[
    { label: 'Rename', onClick: () => rename(id) },
    { label: 'Delete', danger: true, onClick: () => remove(id) },
  ]}
>
  <div className="rounded border p-4">Right-click this card</div>
</ContextMenu>;

API

PropTypeDefaultDescription
children*ReactNode—Target region that opens the menu on right-click.
items*ContextMenuItem[]—Menu entries, including separators and nested items.

On this page