ContextMenu
Responsive Apple Liquid Glass context menu opening a macOS 27 floating Liquid Glass menu on desktop right-click, and a swipe-to-dismiss iOS 27 bottom Liquid Glass Drawer with submenu drill-down on mobile long-press.
Fully compatible with the standard shadcn/ui JSX API (<ContextMenu> / <ContextMenuTrigger> / <ContextMenuContent> / <ContextMenuGroup> / <ContextMenuItem> / <ContextMenuCheckboxItem> / <ContextMenuRadioGroup> / <ContextMenuSub>), adapting automatically via useIsMobile() (768px):
- Desktop (
>= 768px· macOS 27): Powered by@base-ui/react/context-menu, right-clicking inside the trigger opens a floating14px-radius Liquid Glass menu with#0069F9hover highlight, keyboard shortcuts, and cascading submenus. - Mobile (
< 768px· iOS 27): Suppresses native text callouts (select-none [-webkit-touch-callout:none]); long-pressing (450ms, canceled on scroll) or right-clicking opens a32pxtop-radius iOS 27 bottom Liquid Glass Drawer with grouped cards, swipe-to-dismiss, and submenu‹ Backnavigation.
Responsive Live Preview
Right-click the file card below on desktop; switch to the Mobile icon top-right to long-press or right-click and explore the bottom Liquid Glass Drawer and "Open With" submenu navigation:
Installation (Shadcn Registry)
# Install via the configured @apple-liquid namespace (includes drawer, liquid-surface, use-mobile, and liquid-glass)
npx shadcn@latest add @apple-liquid/context-menu
# Or install directly via URL
npx shadcn@latest add https://your-domain.com/r/context-menu.jsonCanvas Options (Checkbox & Radio)
Combine ContextMenuCheckboxItem and ContextMenuRadioGroup for canvas guides and zoom levels, with checkmarks consistently aligned on the right:
Usage
import {
ContextMenu,
ContextMenuContent,
ContextMenuGroup,
ContextMenuItem,
ContextMenuLabel,
ContextMenuSeparator,
ContextMenuShortcut,
ContextMenuTrigger,
} from '@/components/ui/context-menu';
export function Example() {
return (
<ContextMenu>
<ContextMenuTrigger className="flex h-36 w-64 items-center justify-center rounded-2xl border border-dashed text-sm">
Right-click (or long-press) here
</ContextMenuTrigger>
<ContextMenuContent title="Actions" className="w-56">
<ContextMenuGroup>
<ContextMenuLabel>Edit</ContextMenuLabel>
<ContextMenuItem>
Copy
<ContextMenuShortcut>⌘C</ContextMenuShortcut>
</ContextMenuItem>
<ContextMenuItem>
Rename
<ContextMenuShortcut>↩</ContextMenuShortcut>
</ContextMenuItem>
</ContextMenuGroup>
<ContextMenuSeparator />
<ContextMenuItem variant="destructive">
Delete
<ContextMenuShortcut>⌘⌫</ContextMenuShortcut>
</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
);
}Props API
ContextMenuContent
| Prop | Type | Default | Description |
|---|---|---|---|
glass | boolean | true | Liquid Glass material reacting to glass tint; false renders a 100% opaque surface |
title | React.ReactNode | — | Centered header title for the mobile bottom Drawer (automatically updates to submenu title with back button when drilling down) |
side | 'top' | 'bottom' | 'left' | 'right' | 'right' | Desktop only: popup side relative to the pointer anchor |
align | 'start' | 'center' | 'end' | 'start' | Desktop only: alignment along the popup axis |
sideOffset | number | 2 | Desktop only: offset in px from the pointer anchor |
alignOffset | number | 4 | Desktop only: offset in px along the alignment axis |
ContextMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'destructive' | 'default' | destructive applies Apple Red destructive styling |
inset | boolean | false | Adds leading indentation to align with items that have icons |
closeOnClick | boolean | true | Automatically close the menu / Drawer after selection |
disabled | boolean | false | Disable interaction |
ContextMenuSubContent
| Prop | Type | Default | Description |
|---|---|---|---|
side | 'top' | 'bottom' | 'left' | 'right' | 'right' | Desktop only: submenu side (mobile uses in-Drawer drill-down with Back button) |
sideOffset | number | 4 | Desktop only: gap in px from the parent menu |
Language & Text
ContextMenu accepts locale and messages, which apply to all of its parts and the overlays it opens and win over the global <LiquidGlassProvider locale messages>. To override the text globally, put it under messages.contextMenu on the provider. See Liquid Glass → Global settings.
| Prop | Type | Description |
|---|---|---|
locale | LiquidGlassLocaleInput | UI language of this component (any BCP 47 tag; unsupported ones fall back to English) |
messages | Partial<ContextMenuMessages> | Text overrides, merged over the built-in text and the global messages.contextMenu |
| Key | Built-in text (English) |
|---|---|
back | Back |
title | Context menu |
Command
Responsive macOS 27 Spotlight-style Liquid Glass command palette supporting custom keyboard shortcuts on desktop, and automatically adapting to a swipe-to-dismiss iOS 27 bottom Liquid Glass Drawer with grouped rows on mobile.
Dialog
Apple Liquid Glass centered dialog with unified desktop and mobile modal presentation, a built-in maximize-to-fullscreen toggle, and fixed header/footer layout with scrollable body.