Glin UI
Primitive / Moleculebeta

Context Menu

Right-click menu with items, checkbox and radio items, submenus and shortcuts.

Edit on GitHub

Design assets

Right click anywhere
  • brand-guidelines.pdf4.2 MB
  • hero-banner.png1.1 MB
  • Roadmap12 items

On touch screens, press and hold. On a keyboard, use Shift F10.

Installation

Install from
pnpm dlx @glinui/cli@latest add context-menu

Prefer the package?

Usage

Canvas

A menu for an empty canvas, with checkable view options.

Right click the canvas
"use client"
import { Globe, Plus } from "@phosphor-icons/react"
import {
ContextMenu,
ContextMenuCheckboxItem,
ContextMenuContent,
ContextMenuItem,
ContextMenuSeparator,
ContextMenuShortcut,
ContextMenuTrigger
} from "@glinui/ui"
export function ContextCanvasExample() {
return (
<div className="mx-auto w-full max-w-md">
<ContextMenu>
<ContextMenuTrigger className="flex h-40 items-center justify-center rounded-2xl border border-dashed border-[var(--color-border)] bg-[var(--surface-1)] text-sm text-[var(--color-muted)]">
Right click the canvas
</ContextMenuTrigger>
<ContextMenuContent className="w-56">
<ContextMenuItem><Plus aria-hidden="true" className="size-4" />New frame <ContextMenuShortcut>F</ContextMenuShortcut></ContextMenuItem>
<ContextMenuItem><Globe aria-hidden="true" className="size-4" />Paste here <ContextMenuShortcut>Ctrl V</ContextMenuShortcut></ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuCheckboxItem checked>Show grid</ContextMenuCheckboxItem>
<ContextMenuCheckboxItem>Snap to objects</ContextMenuCheckboxItem>
</ContextMenuContent>
</ContextMenu>
</div>
)
}

Variants

Every look of the shared vocabulary: glinr (the default), plain (shadcn), solid, soft, outline, ghost, gradient and glass. Omit `variant` to follow the ambient design style.

Right click (glinr)Right click (plain)Right click (solid)Right click (soft)Right click (outline)Right click (ghost)Right click (gradient)Right click (glass)
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger } from "@glinui/ui"
const variants = ["glinr", "plain", "solid", "soft", "outline", "ghost", "gradient", "glass"] as const
export function Demo() {
return (
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
{variants.map((variant) => (
<ContextMenu key={variant} variant={variant}>
<ContextMenuTrigger className="flex h-16 items-center justify-center rounded-lg border border-dashed text-xs">
Right click ({variant})
</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem>Copy</ContextMenuItem>
<ContextMenuItem>Paste</ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuItem>Delete</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
))}
</div>
)
}

Glass (opt-in)

Glass is opt-in and needs a colourful or photographic backdrop. Pick one in the stage header.

Right click here
import { ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut, ContextMenuTrigger } from "@glinui/ui"
export function Demo() {
return (
<ContextMenu variant="glass">
<ContextMenuTrigger className="flex h-32 w-72 items-center justify-center rounded-xl border border-dashed border-[var(--color-border)] text-sm text-[var(--color-muted)]">
Right click here
</ContextMenuTrigger>
<ContextMenuContent className="w-56">
<ContextMenuLabel>Actions</ContextMenuLabel>
<ContextMenuItem>Back <ContextMenuShortcut>Cmd [</ContextMenuShortcut></ContextMenuItem>
<ContextMenuItem>Reload <ContextMenuShortcut>Cmd R</ContextMenuShortcut></ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuCheckboxItem checked>Show bookmarks</ContextMenuCheckboxItem>
</ContextMenuContent>
</ContextMenu>
)
}

Accessibility

  • Opens on right click, long press on touch, or the keyboard context menu key.
  • Focus moves into the menu and returns to the trigger on close.
  • Check and radio items expose their checked state.

Keyboard Interactions

KeyAction
Shift + F10 / Menu keyOpen the menu from the focused trigger.
ArrowUp / ArrowDownMove between items.
ArrowRight / ArrowLeftOpen or close a submenu.
Enter / SpaceSelect the focused item.
EscapeClose the menu.

ARIA Attributes

  • `role="menu"` and `menuitem`
  • `aria-checked` on checkbox and radio items
  • `aria-disabled` on disabled items

Reduced Motion

Panels fade and scale from 95% on open using transform and opacity only. With prefers-reduced-motion the animation is removed.

Affected properties

opacitytransform

API Reference

ContextMenu

PropTypeRequiredDefaultDescription
variantContextMenuVariantNoambient style (glinr)Panel surface for content and submenus. Omit it for the ambient design style. `glass` is opt-in and needs a backdrop.
onOpenChange(open: boolean) => void--Called when the menu opens or closes.
modalboolean-trueBlock outside interaction while open.

ContextMenuItem and friends

PropTypeRequiredDefaultDescription
insetboolean-falseItem and label: add start padding to align with items that have indicators.
disabledboolean-falseItem: blocks selection and focus.
onSelect(event: Event) => void--Item: called on selection.
variantContextMenuVariantNo-Surface look. Omit for the ambient design style (glinr by default). `glass` is opt-in and needs a rich backdrop.

Source

Import directly from the package or browse the source on GitHub. Click any file to view it.

Import

import { ContextMenu } from "@glinui/ui"

Source Files

Dependencies

@glinui/ui@phosphor-icons/react@radix-ui/react-context-menuclass-variance-authority

Generated API Snapshot

Beta

Auto-extracted from TypeScript source in packages/ui/src/components/context-menu.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.

Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata

Primary Props Type

ContextMenuProps

ContextMenuContentProps

PropTypeRequiredDefaultDescription
variantContextMenuVariantNo-Surface look. Omit for the ambient design style (glinr by default). `glass` is opt-in and needs a rich backdrop.

ContextMenuProps

PropTypeRequiredDefaultDescription
variantContextMenuVariantNo-Surface treatment shared by every floating panel in this menu.