A right-click (or long-press) menu for files, kanban cards, chart nodes and table rows. Same parts and the same MenuEntry[] data as Dropdown Menu, so one model can drive both.
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { ContextMenu } from "@vamos-ui/react";
<ContextMenu items={fileActions}>
<FileTile file={file} />
</ContextMenu>Right-click can't be the only way in. Give every action a keyboard and touch path too — usually the row's ActionMenu with the same entries.
Opens with right-click, Shift+F10 or the Menu key on the focused trigger, and long-press on touch.
Keyboard inside the menu works like Dropdown Menu: arrows, Home/End, typeahead, → for submenus, Escape to close.
Examples
Media library grid
File actions in a CMS media grid: a label, shortcuts, a checkbox entry, a submenu and a danger entry — all from data.
API
ContextMenu
| Prop | Type | Default |
|---|---|---|
itemsData-driven mode: children become the right-click area. Without items, ContextMenu is the compound root. | MenuEntry[] | — |
childrenWith items: a single element (rendered with asChild). Without: ContextMenuTrigger + ContextMenuContent. | ReactNode | — |
disabledLet the native browser menu through. | boolean | false |
sizeContent size in data-driven mode. | "sm" | "md" | "md" |
contentPropsExtra props for the content in data-driven mode. | ContextMenuContentProps | — |
onOpenChangeCalled when it opens or closes (select the row/tile here). | (open: boolean) => void | — |
modalBlock outside interaction while open. | boolean | true |
ContextMenuTrigger
| Prop | Type | Default |
|---|---|---|
asChildMerge onto your own element. | boolean | false |
disabledNative menu instead. | boolean | false |
ContextMenuContent
| Prop | Type | Default |
|---|---|---|
sizeMin width 180 / 220 px. | "sm" | "md" | "md" |
loopArrow keys wrap around. | boolean | false |
collisionPaddingDistance kept from the viewport edge. | number | 12 |
Items
| Prop | Type | Default |
|---|---|---|
ContextMenuItemSame API as DropdownMenuItem. | icon · description · shortcut · badge · tone · inset · onSelect · asChild | — |
ContextMenuCheckboxItemmenuitemcheckbox. | checked · onCheckedChange · shortcut | — |
ContextMenuRadioGroup / ContextMenuRadioItemmenuitemradio. | value · onValueChange / value | — |
ContextMenuSub / SubTrigger / SubContentSubmenus; one layer deeper. | icon · size | — |
ContextMenuLabel / Separator / GroupStructure. | inset | — |
ContextMenuEntriesRender MenuEntry[] inside your own ContextMenuContent. | { items: MenuEntry[] } | — |