Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Context Menu

Displays a menu of actions or options triggered by right-clicking an element.

Right click here

Installation

npx logic2b@next add context-menu

Usage

import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuTrigger,
} from "@/components/ui/context-menu"

<ContextMenu>
  <ContextMenuTrigger>Right click here</ContextMenuTrigger>
  <ContextMenuContent>
    <ContextMenuItem>Back</ContextMenuItem>
    <ContextMenuItem>Reload</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

Examples

Checkboxes & Radios

Right click here

With Submenu

Right click here

Accessibility

  • Opens on right-click (or the context-menu key) and can be navigated entirely with the arrow keys; Enter or Space activates the focused item.
  • Wraps Radix Context Menu, which manages role="menu", menuitem, menuitemcheckbox and menuitemradio semantics for you.
  • Typeahead lets users jump to an item by typing its label; Escape closes the menu and returns focus to the trigger.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<ContextMenu
  modal
>
  <ContextMenuTrigger
    className="flex h-36 w-72 items-center justify-center rounded-lg border border-dashed text-sm text-muted-foreground"
  >Right-click this surface</ContextMenuTrigger>
  <ContextMenuContent>
    <ContextMenuLabel>Project</ContextMenuLabel>
    <ContextMenuItem>Open documentation</ContextMenuItem>
    <ContextMenuItem>Copy install command</ContextMenuItem>
    <ContextMenuSeparator />
    <ContextMenuItem
      variant="destructive"
    >Remove project</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

API reference

Generated from the public TypeScript exports in src/ui/context-menu.tsx.

View JSON

ContextMenu

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Root>

ContextMenuTrigger

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>

ContextMenuContent

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Content>

ContextMenuItem

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Item> & { inset?: boolean variant?: "default" | "destructive" }
PropTypeRequiredDefaultDescription
insetbooleanNo——
variant"default" | "destructive"No"default"—

ContextMenuCheckboxItem

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>

ContextMenuRadioItem

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>

ContextMenuLabel

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Label> & { inset?: boolean }
PropTypeRequiredDefaultDescription
insetbooleanNo——

ContextMenuSeparator

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Separator>

ContextMenuShortcut

Component
Props: React.ComponentProps<"span">

ContextMenuGroup

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Group>

ContextMenuPortal

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Portal>

ContextMenuSub

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.Sub>

ContextMenuSubContent

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>

ContextMenuSubTrigger

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & { inset?: boolean }
PropTypeRequiredDefaultDescription
insetbooleanNo——

ContextMenuRadioGroup

Component
Props: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>

Accessibility contract

Machine-readable behavior and consumer responsibilities for context-menu.

View JSON
Support
Primitive-managed
Pattern
context menu
Radix Context Menu
Keyboard interactions for context-menu
KeysBehavior
Shift+F10 ContextMenuOpen the context menu from the keyboard.
ArrowUp ArrowDown ArrowLeft ArrowRightMove within the composite control.
EscapeClose the open surface and restore focus.

Built-in semantics

  • Manages menu roles, roving focus and checked state.

Consumer responsibilities

  • Ensure every pointer-only context action is available through another keyboard-reachable path.