Context Menu

A menu that appears at the pointer on right click or long press.

Right click here

Installation

pnpm dlx shadcn@latest add @lumi-ui/context-menu

Anatomy

<ContextMenu>
  <ContextMenuTrigger />
  <ContextMenuContent>
    <ContextMenuItem />
    <ContextMenuLinkItem />
    <ContextMenuItem>
      <ContextMenuShortcut />
    </ContextMenuItem>
    <ContextMenuSeparator />
    <ContextMenuGroup>
      <ContextMenuLabel />
    </ContextMenuGroup>
    <ContextMenuRadioGroup>
      <ContextMenuRadioItemContent />
    </ContextMenuRadioGroup>
    <ContextMenuCheckboxItemContent />
    <ContextMenuSub>
      <ContextMenuSubTriggerGroup />
      <ContextMenuSubContent>
        {/* Submenu items */}
      </ContextMenuSubContent>
    </ContextMenuSub>
  </ContextMenuContent>
</ContextMenu>

Basic Usage

Right click here

Features

Composite Ergonomics

Right click for composite helpers

Primitive Control

Right click for primitive-level composition

Item Variants

Right click to inspect item variants

API Reference

ContextMenuContent

A high-level container component that combines ContextMenuPortal, ContextMenuPositioner, and ContextMenuPopup into a single styled content element.

PropTypeDescription
side"top" | "right" | "bottom" | "left"The preferred side of the anchor to render against when open.
sideOffsetnumberThe distance in pixels from the anchor.
align"start" | "center" | "end"The preferred alignment against the anchor.
alignOffsetnumberAn offset in pixels from the "start" or "end" alignment options.
showArrowbooleanWhether to render the arrow element.
matchAnchorWidthbooleanWhether the popup width should match the anchor width.
classNamestringAdditional CSS classes.
...propsBaseContextMenu.Popup.PropsPasses all other props to the underlying popup component.

ContextMenuCheckboxItemContent

A high-level checkbox item component that combines ContextMenuCheckboxItem and CheckboxItemIndicator into a single styled element with configurable indicator placement.

PropTypeDescription
indicatorPlacement"start" | "end"The position of the indicator icon relative to the content.
indicatorIconReact.ReactNodeThe icon to render as the checked indicator.
classNamestringAdditional CSS classes.
...propsBaseContextMenu.CheckboxItem.PropsPasses all other props to the underlying checkbox item component.

ContextMenuRadioItemContent

A high-level radio item component that combines ContextMenuRadioItem and RadioItemIndicator into a single styled element with configurable indicator placement.

PropTypeDescription
indicatorPlacement"start" | "end"The position of the indicator icon relative to the content.
indicatorIconReact.ReactNodeThe icon to render as the selected indicator.
classNamestringAdditional CSS classes.
...propsBaseContextMenu.RadioItem.PropsPasses all other props to the underlying radio item component.

ContextMenuSubTriggerGroup

A composite submenu trigger component that renders trigger content and a chevron icon while reusing context menu item variants.

PropTypeDescription
variant"default" | "destructive" | "inset"The visual style variant applied to the trigger row.
unstyledbooleanDisables built-in trigger styling when true.
classNamestringAdditional CSS classes.
childrenReact.ReactNodeThe content of the trigger.
...propsBaseContextMenu.SubmenuTrigger.PropsPasses all other props to the underlying submenu trigger component.

ContextMenuSubContent

A composite content component for submenus.

PropTypeDescription
side"top" | "right" | "bottom" | "left"The preferred side of the anchor to render against when open.
sideOffsetnumberThe distance in pixels from the anchor.
align"start" | "center" | "end"The preferred alignment against the anchor.
alignOffsetnumberAn offset in pixels from the "start" or "end" alignment options.
classNamestringAdditional CSS classes.
...propsContextMenuContentPropsPasses all other props to the underlying ContextMenuContent component.