Getting StartedInstall and bootstrap headless foundations 4
LayoutHeadless structural primitives for expandable and container patterns 6
OverlayHeadless modal and floating layer behavior 3
FeedbackHeadless notification and status communication patterns 5
FormHeadless input and selection contracts 17
UtilityReusable action, identity, and clipboard behavior 6
NavigationHeadless trails, trees, menus, and command surfaces 7

Context Menu overview

Headless context menu adds right-click and keyboard context invocation on top of tngMenu while leaving the trigger surface, panel placement, and styling in your hands.

Primitive imports

ts
import {
  TngContextMenu,
  TngContextMenuTrigger,
  TngMenu,
  TngMenuGroupLabel,
  TngMenuItem,
  TngMenuSeparator,
} from '@tailng-ui/primitives';

Basic composition

Apply tngContextMenuTrigger to any focusable target, then add tngContextMenu on the menu host that already owns tngMenu. The exported instance exposes whether the menu opened from a pointer or keyboard anchor.

Headless context-menu composition

html
<div class="context-shell">
  <div tabindex="0" [tngContextMenuTrigger]="assetMenu">Right-click target</div>
  <div tngMenu tngContextMenu #assetMenu="tngContextMenu" aria-label="Asset actions">
    <button type="button" tngMenuItem tngMenuItemValue="rename">Rename</button>
    <button type="button" tngMenuItem tngMenuItemValue="archive">Archive</button>
  </div>
</div>
<!-- Read assetMenu.getAnchorType() / getPointerAnchor() when you want cursor placement. -->

Style variants

The same primitive markup rendered through a plain CSS contract or wrapper-scoped Tailwind selectors.

Headless context menu (plain CSS)

Last command: No command yet

Keyboard baseline

  • Shift + F10 or ContextMenu opens from the focused target.
  • ArrowDown/ArrowUp traverses enabled actions.
  • Enter/Space activates the highlighted action.
  • Escape closes the menu and restores focus to the trigger target.