Skip to Content
Liquid Glass UI
Components

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 floating 14px-radius Liquid Glass menu with #0069F9 hover 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 a 32px top-radius iOS 27 bottom Liquid Glass Drawer with grouped cards, swipe-to-dismiss, and submenu ‹ Back navigation.

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:

apple-liquid-ui/preview/context-menu-liquid-hero
MacBook · 16:10

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.json

Canvas Options (Checkbox & Radio)

Combine ContextMenuCheckboxItem and ContextMenuRadioGroup for canvas guides and zoom levels, with checkmarks consistently aligned on the right:

apple-liquid-ui/preview/context-menu-view-options
MacBook · 16:10

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

PropTypeDefaultDescription
glassbooleantrueLiquid Glass material reacting to glass tint; false renders a 100% opaque surface
titleReact.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
sideOffsetnumber2Desktop only: offset in px from the pointer anchor
alignOffsetnumber4Desktop only: offset in px along the alignment axis

ContextMenuItem

PropTypeDefaultDescription
variant'default' | 'destructive''default'destructive applies Apple Red destructive styling
insetbooleanfalseAdds leading indentation to align with items that have icons
closeOnClickbooleantrueAutomatically close the menu / Drawer after selection
disabledbooleanfalseDisable interaction

ContextMenuSubContent

PropTypeDefaultDescription
side'top' | 'bottom' | 'left' | 'right''right'Desktop only: submenu side (mobile uses in-Drawer drill-down with Back button)
sideOffsetnumber4Desktop 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.

PropTypeDescription
localeLiquidGlassLocaleInputUI language of this component (any BCP 47 tag; unsupported ones fall back to English)
messagesPartial<ContextMenuMessages>Text overrides, merged over the built-in text and the global messages.contextMenu
KeyBuilt-in text (English)
backBack
titleContext menu

On this page