Context menu
Right-click here, or press Shift+F10.
npx shadcn add @klarhimmel/context-menu @klarhimmel/menuCopy for AIExamples
Basic
Rows
Tiles
DetailsAbout, usage, props and more
The menu that opens where you right-click, and from the keyboard with the Menu key or Shift+F10.
When to use
Use for
Row, tile and canvas actions for mouse and keyboard users.
Not for
The only route to an action. Touch has no right-click: repeat the actions in a visible button.
Pairs with
Menu, Icon button, tables and file grids.
Preview
Booking 4821
Right-click here, or focus it and press the Menu key or Shift+F10.
Nothing chosen yet.
Import
Import
- Files
- context-menu.tsx, menu.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react, radix-ui.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
- Limit
- Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | required | Required: names the area. It is a tab stop, so keyboard users can reach the menu too. |
children | ReactNode | required | What the area shows. |
menu | ReactNode | required | The menu: MenuItem, MenuLabel, MenuSeparator... from Menu. |
className | string | - | Extra classes, merged after the component's own. |
Accessibility
| Key | Does |
|---|---|
Right-click | Opens the menu at the pointer |
Menu key / Shift+F10 | Opens it at the focused element |
Down / Up / Home / End | Move through the items |
Letters | Jump to an item that starts with them |
Escape | Closes and returns focus to the area |
It is the same Menu as a button's menu. The area is a named tab stop so keyboard users can reach it.
Accessibility