Context Menu
Overlay
Navigation
Right-click context menu with keyboard navigation and custom actions.
Preview
Right-click a file row, or focus it and press Shift+F10, to open the context menu. The open state is shown next to the list.
Q4 roadmap.pdf
PDF, 2.4 MB
Brand guidelines.pdf
PDF, 8.1 MB
Release notes.md
Markdown, 12 KB
With Section Labels
Organize menu items with section headers
Project Document
Right-click to see organized menu with labels
Props
Component API reference
ContextMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
icon | LucideIcon | — | Icon component to display |
shortcut | string | — | Keyboard shortcut text |
destructive | boolean | false | Destructive action styling |
disabled | boolean | false | Disable the menu item |
onSelect | () => void | — | Click handler |
ContextMenuLabel
| Prop | Type | Default | Description |
|---|---|---|---|
children* | ReactNode | — | Label text content |
Usage
Import and implementation examples
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuLabel,} from '@/components/ui/context-menu'import { Copy, Edit, Trash2 } from 'lucide-react'
<ContextMenu> <ContextMenuTrigger> <div>Right-click me!</div> </ContextMenuTrigger> <ContextMenuContent> <ContextMenuItem icon={Copy} shortcut="⌘C"> Copy </ContextMenuItem> <ContextMenuItem icon={Edit} shortcut="⌘E"> Edit </ContextMenuItem> <ContextMenuSeparator /> <ContextMenuLabel>Danger Zone</ContextMenuLabel> <ContextMenuItem icon={Trash2} destructive> Delete </ContextMenuItem> </ContextMenuContent></ContextMenu>Features
Built-in functionality
- Right-click trigger: Opens at the pointer, or at the trigger from the keyboard
- Keyboard shortcuts: Display shortcut hints
- Section labels: Group related items with headers
- Destructive styling: Red color for dangerous actions
- Icon support: Add icons to menu items
- Separators: Visual dividers between sections
- Click outside: Closes when clicking outside
Accessibility
Accessibility considerations
ARIA Attributes
Built on Radix Context Menurole="menu" for menu containerrole="menuitem" for itemsaria-disabled for disabled itemsKeyboard Navigation
| Key | Action |
|---|---|
| Shift+F10 / Menu key | Open the menu from the focused trigger |
| Arrow Up/Down | Navigate items |
| Home/End | First or last item |
| Letter keys | Jump to the item that starts with the letter |
| Enter/Space | Activate item |
| Escape | Close menu |
Notes
- The trigger is focusable, so the menu works without a mouse
- Focus moves into the menu on open and back to the trigger on close
- Click outside closes the menu
- Long press opens the menu on touch screens