Skip to content
Redpanda UI
Esc
↑↓navigate↵open⌘Jpreview
Made by shadcn
Edit on GitHub

Context Menu

Displays a menu of actions or functions at the pointer when the user right-clicks an element, with submenus, checkboxes and shortcuts.

Installation

bash
npx shadcn@latest add @redpanda/context-menu
bash
pnpm dlx shadcn@latest add @redpanda/context-menu
bash
yarn dlx shadcn@latest add @redpanda/context-menu
bash
bunx shadcn@latest add @redpanda/context-menu
bash
nubx shadcn@latest add @redpanda/context-menu
bash
aube dlx shadcn@latest add @redpanda/context-menu

When to use

Use this decision tree to determine when to use the Context Menu component:

Usage

tsx
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from '@/components/ui/context-menu';
tsx
<ContextMenu>  <ContextMenuTrigger>Right click</ContextMenuTrigger>  <ContextMenuContent>    <ContextMenuItem>Profile</ContextMenuItem>    <ContextMenuItem>Billing</ContextMenuItem>    <ContextMenuItem>Team</ContextMenuItem>    <ContextMenuItem>Subscription</ContextMenuItem>  </ContextMenuContent></ContextMenu>

Examples

Checkbox items

Radio group

Grouped actions

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 via aria-haspopup="menu" — screen-reader users can reach the menu without a pointing device by pressing Shift+F10 while 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 baseline while caret semantics still allow any compatible release within the same major.#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## 🚧 Updated#112
See full history →

Last updated on

Was this page helpful?