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

API reference

Headless context menu is a thin trigger layer on top of tngMenu. The context directive captures whether an open came from pointer coordinates or a keyboard anchor and lets owners use that state for their own placement logic.

tngContextMenu

Apply tngContextMenu on the same host as tngMenu. The directive exports as tngContextMenu and delegates open and close behavior to the linked menu instance.

Context trigger + 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>
  </div>
</div>
CapabilityDetails
exportAstngContextMenu
Host requirementMust share the same host injector as tngMenu.
Open stateisOpen() and close(restoreFocus) proxy the hosted menu.
Anchor state Tracks 'pointer' vs 'element' opens and stores the last pointer coordinates from a right-click invocation.

tngContextMenuTrigger

Link any focusable target to a context menu instance with [tngContextMenuTrigger]. The directive listens for contextmenu, Shift + F10, and the ContextMenu keyboard key.

Input / HostTypeDetails
[tngContextMenuTrigger]TngContextMenu | nullRequired reference to the exported context menu instance.
data-slot'context-menu-trigger'Stable styling hook for right-click affordances and focus treatment.
Host attributesid, aria-haspopup, aria-controls, aria-expandedReflects the relationship to the linked menu surface and current open state.
Disabled hostsnative / ARIAHonors disabled, disabled attribute, or aria-disabled="true".

Exported instance

MethodTypeDescription
isOpen()booleanCurrent open state for the linked context menu.
close(restoreFocus)(restoreFocus: boolean) => voidCloses the panel and optionally restores focus to the trigger target.
getAnchorType()'pointer' | 'element' | nullWhether the current open came from right-click coordinates or keyboard context invocation.
getPointerAnchor()TngContextMenuPointerAnchor | nullViewport client coordinates captured during a pointer open. Returns null for keyboard opens.

Keyboard contract

Context-menu keyboard baseline

text
Target
  Shift + F10 / ContextMenu : open from the focused target
  Escape                    : close if open

Open menu
  ArrowDown / ArrowUp       : move active item
  Home / End                : jump to first / last enabled item
  Enter / Space             : activate current item
  Escape                    : close and restore focus to the target