Context menu
A React component in Beamline's Overlays category, in the free sample.
Actions for an object on right-click, long-press, Shift+F10 or the menu key, opened at the pointer, with the same rows as the dropdown menu.
Use it for
- Right-click actions on an object: a file, a row, a canvas node.
Not for
- The only way to reach an action: always mirror it in a visible menu or button (dropdown-menu).
Anatomy
- target (your element, focusable)
- surface
- highlight plate
- rows: item, check item, radio item, heading, separator, submenu
Variants
- tone: default, danger
States
- closed
- open
- item highlighted
- item disabled
- check on/off
- submenu open
Keyboard
- Shift+F10 or the menu key on the focused target opens
- ↑ ↓ move, wrapping
- → opens a submenu, ← closes it
- type a letter to jump
- Escape closes and returns focus
Motion
Same surface and gliding highlight as the dropdown menu. Opens out of its trigger (for a context menu, out of the point that was pressed) (_shared/overlay.module.css, source morph): the layer starts as the trigger's own box, offset onto it, and grows; the side next to the trigger is there at once so the nearest rows read within the ruled 90 ms, the far side settles by ~200 ms, content fades in over 90 ms; it closes back into the trigger in 180 ms. Until it has grown the press that opened it cannot land on a row. Every row acknowledges a press at once (a tint over the plate) before the menu closes or the row toggles; a check grows into its row as the value changes (--pui-motion-in). The surface is never wider or taller than the room beside its trigger. Reduced motion: it fades.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | The menu's accessible name, e.g. "File actions". |
items | MenuItem[] (shared with dropdown-menu and menubar) | — | The same rows as DropdownMenu: icons, shortcuts, danger, check items, headings, submenus. |
children | ReactElement | — | The object the menu belongs to: one element that can take a ref. Make it focusable (tabIndex={0}) so Shift+F10 and the menu key reach it. |
disabled | boolean | — | Ignore right-clicks (the browser's own menu shows). |
onOpenChange | (open: boolean) => void | — | Reports open state after a change; no callback by default. |
classNames | MenuClassNames | — | Classes for the named visual parts; no part overrides by default. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
className | string | — | Classes on the documented visual root; no override by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
ref | Ref<HTMLDivElement> | — | Receives the documented root element; no ref by default. |
dir | "ltr" | "rtl" | — | Reading direction; inherits the surrounding direction when omitted. Defaults to the surrounding reading direction. |
Used in
- Action center
- Admin users
- Agent runs monitor
- Bulk item edit
- Change orders
- Collection batch edit
- CRM pipeline
- File manager
- Hiring pipeline
- Invoices
- Market screener
- Order history and fills
- Orders admin
- Portfolio overview
- Return queue
- Submittal register
- Workflow builder
Dependencies
@radix-ui/react-context-menu, lucide-react
Import
import { ContextMenu } from "@beamline/context-menu";
Get it
Context menu is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Context menu is included in the free MIT sample. Get Beamline · Connect your agent
More in Overlays
- Command menu: Search-first list of every action: ranked matching, groups, keycap shortcuts and nested pages; inline as CommandPalette or in a ⌘K dialog as CommandMenu.
- Toast: Short results of an action stacked at an edge: point at the stack to fan it out and pause the timers; undo or retry in place; Alt+T, Escape and a swipe…
- Share dialog: Share a document, board or project: invite people by name or email with the access they get, change or remove anyone's access in place, and set who the…
- Hover card: A preview of a person, link or record on hover or keyboard focus, without leaving the page; HoverCardProfile is the standard person preview.
- Product tour: A short guided tour over the real interface: a spotlight that glides from one element to the next while the rest of the screen dims, and a card beside…
- Bottom sheet: A phone panel that rests at a peek and follows the finger to full height; a flick down closes it, and the handle works from the keyboard.
- Sheet: A panel that slides in from an edge with the page still visible behind it: header and footer stay put while the body scrolls.
- Dropdown menu: A list of actions behind a trigger, with shortcuts, check items, headings and submenus; one highlight glides under the pointer and jumps with the keyboard.
- Dialog: A focused task over the page (create, invite, rename) with a title, body and footer; focus moves in, is trapped and returns on close.
- Alert Dialog: A blocking confirmation that must be answered: the scrim does not dismiss it, focus starts on the safe choice, and an async action keeps it open until…
- Popover: A small surface anchored to a trigger for a short form, a filter or an explanation; focus moves in and returns on close.
- Tooltip: Short supporting text for a control: opens after a moment on hover and at once on keyboard focus; inside a toolbar group the next one opens instantly.