Context Menu
Displays a menu to the user — such as a set of actions or functions — triggered by a button.
Made by shadcnInstallation
Loading component...
When to use
Use this decision tree to determine when to use the Context Menu component:
Usage
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuTrigger,
} from "@/components/ui/context-menu"<ContextMenu>
<ContextMenuTrigger>Right click</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem>Profile</ContextMenuItem>
<ContextMenuItem>Billing</ContextMenuItem>
<ContextMenuItem>Team</ContextMenuItem>
<ContextMenuItem>Subscription</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>Examples
Submenu
Loading component...
Checkbox items
Loading component...
Radio group
Loading component...
Grouped actions
Loading component...
Props
Keyboard interactions
| Key | Action |
|---|---|
Shift+F10 on the trigger | Opens the context menu (standards-compliant keyboard equivalent of right-click). |
ArrowUp / ArrowDown | Moves between items. Wraps at the edges. |
ArrowLeft / ArrowRight | Opens / closes submenus. |
Home / End | Jumps to first / last item. |
Enter / Space | Activates the focused item. |
Escape | Closes the menu. |
| Typing a character | Typeahead jumps to the next matching item. |
Accessibility
- The trigger region is marked
role="group"and advertises the context menu viaaria-haspopup="menu"— screen-reader users can reach the menu without a pointing device by pressingShift+F10while focused inside. - Menu items adopt
role="menuitem"/menuitemcheckbox/menuitemradio, with roving focus inside the popup. - Use a visible outline / ring on the trigger region so keyboard users know where to press
Shift+F10. - Keep context-menu-only actions non-essential — mirror every action elsewhere (toolbar, main menu) so pointer-restricted users are not blocked.
Credits
- We use Base UI for the context-menu component.
- We take our inspiration from Shadcn UI for the context-menu style.
Recent changes
- patchv1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested b…#133
- minorv1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
- minorv1.0.0Post-Base-UI polish. Public API unchanged.#116
- majorv1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
- patchv0.3.1**Accordion** - `AccordionTrigger` now shows `cursor-pointer` on hover.#112
Built by malinskibeniamin. The source code is available on GitHub.