Navigation

Context Menu

Displays a menu to the user, opened on right-click or a long press.

Preview
01 Installation

Install

Pull Context Menu from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { ContextMenu } from "@brika/clay";
tsxGranular1 line
import { ContextMenu } from "@brika/clay/components/context-menu";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxContext Menu.tsx43 lines
'use client';

import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuSeparator,
  ContextMenuShortcut,
  ContextMenuSub,
  ContextMenuSubContent,
  ContextMenuSubTrigger,
  ContextMenuTrigger,
} from '@brika/clay/components/context-menu';
/** Right-click (or long-press on mobile) the target area to open the menu. */
export default function ContextMenuDefaultDemo() {
  return (
    <ContextMenu>
      <ContextMenuTrigger className="flex h-24 w-48 cursor-context-menu items-center justify-center rounded-lg border border-dashed border-input text-muted-foreground text-sm">
        Right-click here
      </ContextMenuTrigger>
      <ContextMenuContent className="w-48">
        <ContextMenuItem>
          New file
          <ContextMenuShortcut>Cmd+N</ContextMenuShortcut>
        </ContextMenuItem>
        <ContextMenuItem>
          Rename
          <ContextMenuShortcut>F2</ContextMenuShortcut>
        </ContextMenuItem>
        <ContextMenuSeparator />
        <ContextMenuSub>
          <ContextMenuSubTrigger>More options</ContextMenuSubTrigger>
          <ContextMenuSubContent>
            <ContextMenuItem>Properties</ContextMenuItem>
            <ContextMenuItem>Compress</ContextMenuItem>
          </ContextMenuSubContent>
        </ContextMenuSub>
        <ContextMenuSeparator />
        <ContextMenuItem variant="destructive">Delete</ContextMenuItem>
      </ContextMenuContent>
    </ContextMenu>
  );
}
03 Examples

Context Menu, every way

Checkbox

ContextMenuCheckboxItem maintains a checked state for toggleable settings.

Radio

ContextMenuRadioGroup enforces a single active choice across a set of items.

04 Accessibility

Accessibility

  • Trigger carries aria-haspopup="menu" automatically.
  • Keyboard: Shift+F10 or the context-menu key opens the menu on the focused trigger.
  • Arrow keys navigate items; Enter/Space activate; Escape dismisses.
  • Destructive items should use variant="destructive" so the visual indication matches AT context.
05 API reference

API reference

Props specific to Context Menu. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

<ContextMenu />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuCheckboxItem />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuContent />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuGroup />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuItem />

2 props
  • boolean
    When true, adds extra leading padding to align with items that have icons.
  • variantdefault 'default'
    'default' | 'destructive'
    "default" or "destructive", destructive renders in red.

<ContextMenuLabel />

1 prop
  • boolean

    No description.

<ContextMenuPortal />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuRadioGroup />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuRadioItem />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuSeparator />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuShortcut />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuSub />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuSubContent />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<ContextMenuSubTrigger />

1 prop
  • boolean

    No description.

<ContextMenuTrigger />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.