Reference index

Components

Context Menu

Context menu on Base UI ContextMenu: focusable area, opens at the pointer or from Shift+F10, ink-fill highlight, hairline separators.

Preview

Right-click here, or focus it and press Shift+F10

Install

bash

npx shadcn add @eloquent/context-menu

Usage

tsx

import {
  ContextMenu, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel,
  ContextMenuSeparator, ContextMenuShortcut, ContextMenuTrigger,
} from "@/components/ui/context-menu";

<ContextMenu>
  <ContextMenuTrigger className="rule-hair flex h-36 items-center justify-center border-b border-ink">
    Right-click here
  </ContextMenuTrigger>
  <ContextMenuContent>
    <ContextMenuGroup>
      <ContextMenuLabel>Page</ContextMenuLabel>
      <ContextMenuItem>Back<ContextMenuShortcut>⌘[</ContextMenuShortcut></ContextMenuItem>
      <ContextMenuItem>Reload</ContextMenuItem>
    </ContextMenuGroup>
    <ContextMenuSeparator />
    <ContextMenuItem variant="destructive">Remove from front page</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

The trigger is a focusable area (tabindex="0"), so keyboard users can open the menu too. Put ContextMenuLabel inside a ContextMenuGroup. The submenu parts are ContextMenuSub, ContextMenuSubTrigger and ContextMenuSubContent.

States

Radio items
Right-click to sort
Destructive and disabled
Right-click a story
StateTreatment
Area focused2px ink outline, 2px offset
OpenPaper popup, 1px ink rule, no shadow
HighlightedInk fill, paper text; it is the menu's focus indicator, so the keyboard and the pointer both move it
Disabledhalftone text, cursor-not-allowed; tint-1 when highlighted
CheckedInk check icon (checkbox), filled ink dot (radio)
DestructiveInk ✕ icon before the label; never red
Submenu opentint-1 band on its row

Keyboard

KeyAction
TabReach the area; it shows the 2px ink outline
Shift+F10 / Menu keyOpen the menu at the area
Right click / long pressOpen the menu at the pointer
ArrowDown / ArrowUpMove the highlight (the first ArrowDown highlights the first row); it wraps
Home / EndFirst or last row
A letterJump to the next row starting with it
Enter / SpaceActivate the row; checkbox and radio rows keep the menu open
ArrowRightOpen a submenu
ArrowLeftClose a submenu and return to its row
EscClose; focus returns to the trigger

Vietnamese

Nhấp chuột phải vào đây, hoặc đưa tiêu điểm vào và nhấn Shift+F10

Ink adaptation

Upstream shadcn's shadow, radius, colour tokens and animation are removed. Rows are Barlow at 44px high, labels are tracked capitals and separators are hairlines. The inventory suggests a tint-1 highlight; the ink fill is used so the keyboard position stays clear (the same reading as Select). Built on Base UI ContextMenu.