Install
Pull Context Menu from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { ContextMenu } from "@brika/clay";import { ContextMenu } from "@brika/clay/components/context-menu";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
'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>
);
}Context Menu, every way
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.
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 />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuCheckboxItem />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuContent />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuGroup />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuItem />
2 props- booleanWhen
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 />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuRadioGroup />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuRadioItem />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuSeparator />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuShortcut />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuSub />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuSubContent />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<ContextMenuSubTrigger />
1 prop- boolean
No description.
<ContextMenuTrigger />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.