Context Menu
A right-click menu with items, shortcuts and keyboard navigation.
Installation
pnpm dlx nachui add context-menuAnatomy
The menu opens at the pointer on right click, on long press on touch devices, and from the keyboard with Shift F10 or the context menu key. It clamps itself to the viewport, and arrow keys, Home, End and Escape work as in any menu.
Composition
Use the following composition to build a
ContextMenu:API Reference
ContextMenu
| Prop | Type | Default | Description |
|---|---|---|---|
onOpenChange | (open: boolean) => void | - | Callback when open state changes |
className | string | - | Additional CSS classes |
ContextMenu.Trigger
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Ignore right clicks and long press |
className | string | - | Additional CSS classes |
ContextMenu.Item
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disable the item |
variant | 'default' | 'destructive' | 'default' | Visual style |
onSelect | () => void | - | Callback when selected |
className | string | - | Additional CSS classes |
ContextMenu.Label
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Label text |
ContextMenu.Shortcut
Right-aligned hint inside an item. Purely visual, it does not register the shortcut.
ContextMenu.Separator
Visual separator between menu items. No props.
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.