Context Menu
Right-click menu for an area, opening at the pointer and flipping at screen edges. Shares Dropdown Menu's items, checkbox and radio items, keyboard and typeahead; Menu key or Shift+F10 opens it from the keyboard.
npx @kznlabs/labsui add context-menuInsane 1v4 clutch
Boss fight, no hits
Funniest fail
Right-click a clip, or focus one and press Shift+F10.
import { Copy, Play, Trash2 } from "lucide-react";import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger,} from "@/components/ui/context-menu";export function ClipCard({ title, onDelete,}: { title: string; onDelete: () => void;}) { return ( <ContextMenu> <ContextMenuTrigger aria-label={title}>{title}</ContextMenuTrigger> <ContextMenuContent> <ContextMenuItem> <Play /> Play </ContextMenuItem> <ContextMenuItem shortcut="⌘C"> <Copy /> Copy link </ContextMenuItem> <ContextMenuSeparator /> <ContextMenuItem variant="destructive" onSelect={onDelete}> <Trash2 /> Delete </ContextMenuItem> </ContextMenuContent> </ContextMenu> );}<ContextMenu>
Right-click menu for an area. The trigger is the area; the menu opens at the pointer.
children*ReactNodeContextMenuTriggerandContextMenuContent.onOpenChange(open: boolean) => voidCalled when the menu opens at the pointer or closes.
| Prop | Type | Default |
|---|---|---|
children*
| ReactNode | — |
onOpenChangeCalled when the menu opens at the pointer or closes. | (open: boolean) => void | — |
<ContextMenuContent>
children*ReactNodeItems, labels, groups and separators.
aligndefault"start""start" | "end"Edge of the trigger the menu lines up with.
| Prop | Type | Default |
|---|---|---|
children*Items, labels, groups and separators. | ReactNode | — |
alignEdge of the trigger the menu lines up with. | "start" | "end" | "start" |
<ContextMenuItem>
children*ReactNodeLabel, optionally with a leading icon.
disabledbooleanShown but not selectable.
onSelect() => voidCalled on click or Enter; the menu then closes.
shortcutstringRight-aligned hint, e.g. "⌘S".
variantdefault"default""default" | "destructive""destructive": red, for irreversible actions.
| Prop | Type | Default |
|---|---|---|
children*Label, optionally with a leading icon. | ReactNode | — |
disabledShown but not selectable. | boolean | — |
onSelectCalled on click or Enter; the menu then closes. | () => void | — |
shortcutRight-aligned hint, e.g. "⌘S". | string | — |
variant"destructive": red, for irreversible actions. | "default" | "destructive" | "default" |
<ContextMenuCheckboxItem>
checked*booleanShows the check mark.
children*ReactNodeLabel, optionally with a leading icon.
onCheckedChange*(checked: boolean) => voidCalled with the new state.
disabledbooleanShown but not selectable.
shortcutstringRight-aligned hint, e.g. "⌘S".
| Prop | Type | Default |
|---|---|---|
checked*Shows the check mark. | boolean | — |
children*Label, optionally with a leading icon. | ReactNode | — |
onCheckedChange*Called with the new state. | (checked: boolean) => void | — |
disabledShown but not selectable. | boolean | — |
shortcutRight-aligned hint, e.g. "⌘S". | string | — |
<ContextMenuRadioGroup>
children*ReactNodeDropdownMenuRadioItems.onValueChange*(value: string) => voidCalled with the picked item's value.
value*stringValue of the checked item.
| Prop | Type | Default |
|---|---|---|
children*
| ReactNode | — |
onValueChange*Called with the picked item's value. | (value: string) => void | — |
value*Value of the checked item. | string | — |
<ContextMenuRadioItem>
children*ReactNodeLabel, optionally with a leading icon.
value*stringChecked when it equals the group's
value.disabledbooleanShown but not selectable.
| Prop | Type | Default |
|---|---|---|
children*Label, optionally with a leading icon. | ReactNode | — |
value*Checked when it equals the group's | string | — |
disabledShown but not selectable. | boolean | — |
<ContextMenuLabel>
Also accepts every <div> prop (none of its own).
<ContextMenuSeparator>
<ContextMenuTrigger>
The right-clickable area. Keyboard: focus it (it is focusable) and press the Menu key or Shift+F10; the menu opens at its center on the first item.
Also accepts every <div> prop (none of its own).
* required. Every component also takes className.