Skip to content

Components

Context Menu

A menu that opens at the pointer on right-click, or with Shift+F10.

Customize
Ombelle · light

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add context-menu

Adds components/ui/context-menu.tsx and installs react, @radix-ui/react-context-menu, clsx, tailwind-merge, lucide-react with lifecycle scripts disabled. This is a client component.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubTrigger, ContextMenuSubContent } from '@/components/ui/context-menu'
export function Example(){return <ContextMenu><ContextMenuTrigger variant="zone" tabIndex={0} aria-label="Layer: Hero card">Right-click or Shift+F10 on a layer</ContextMenuTrigger><ContextMenuContent><ContextMenuItem>Duplicate<ContextMenuShortcut>Ctrl+D</ContextMenuShortcut></ContextMenuItem><ContextMenuSub><ContextMenuSubTrigger>Apply preset</ContextMenuSubTrigger><ContextMenuSubContent><ContextMenuItem>Ombelle</ContextMenuItem><ContextMenuItem>Liquid glass</ContextMenuItem></ContextMenuSubContent></ContextMenuSub><ContextMenuItem>Copy as JSX</ContextMenuItem><ContextMenuSeparator /><ContextMenuItem variant="destructive">Delete<ContextMenuShortcut>Del</ContextMenuShortcut></ContextMenuItem></ContextMenuContent></ContextMenu>}

API and states

API
ContextMenu, ContextMenuTrigger (variant zone), ContextMenuContent, ContextMenuItem (variant destructive), ContextMenuCheckboxItem, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubTrigger, ContextMenuSubContent
Minimum states
Closed, open, highlighted, submenu, destructive, disabled
Native basis
Radix Context Menu; Base UI Context Menu in the Base UI edition
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.