Skip to main content
cngx-src documentation

CngxTooltip

DirectivePrimaryv0.1.0WCAG AA

projects/common/popover/tooltip.directive.ts

Import#

import { CngxTooltip } from '@cngx/common/popover'

Description#

String-input tooltip directive applied to the trigger element.

Creates the tooltip popover element internally via Renderer2 and manages the full lifecycle: hover/focus triggers, open/close delays, Escape dismiss, CSS Anchor Positioning, and ARIA wiring (aria-describedby + role="tooltip").

The consumer sees only the attribute - no extra elements in the template.

Basic

<button cngxTooltip="Ctrl+S">Save</button>

With configuration

<button cngxTooltip="Ctrl+S" tooltipPlacement="top" [tooltipDelay]="500">
  Save
</button>

https://cngxjs.github.io/cngx/examples/#/common/popover/tooltip/basic-tooltip https://cngxjs.github.io/cngx/examples/#/common/popover/tooltip/custom-delay https://cngxjs.github.io/cngx/examples/#/common/popover/tooltip/disabled-state https://cngxjs.github.io/cngx/examples/#/common/popover/tooltip/keyboard-navigation https://cngxjs.github.io/cngx/examples/#/common/popover/tooltip/placement https://cngxjs.github.io/cngx/examples/#/common/popover/tooltip/programmatic-control

Metadata#

Host#

Index#

Inputs#

closeDelay#
input()

Delay in ms before closing on mouseleave.

default 100
enabled#
input()

Whether the tooltip is active. When false, no tooltip appears and ARIA is cleared.

default true
offset#
input()

Gap between trigger and tooltip in px.

default 8, { alias: 'tooltipOffset' }
openDelay#
input()

Delay in ms before opening on mouseenter.

default 300, { alias: 'tooltipDelay' }
input()

Anchor-relative placement.

default 'top', { alias: 'tooltipPlacement' }
input()

CSS <try-tactic> fallbacks for position-try-fallbacks. Empty array (default) means no fallback CSS is written; the tooltip stays at the declared tooltipPlacement regardless of viewport clipping. Tooltips are decorative - collision recovery is opt-in per-tooltip.

default [], { alias: 'tooltipPositionTryFallbacks', }
input()Required

Tooltip text content.

default { alias: 'cngxTooltip' }
input()

Trigger mode. 'auto' (default) opens on hover/focus with the configured delays; 'manual' opts the host out of the hover/focus listeners so only show() / hide() open or close the tooltip. Escape still dismisses an open tooltip in either mode.

default 'auto'

Instance Properties#

state#unknown
Readonly

Current lifecycle state.

this.stateSignal.asReadonly()

Methods#

handleBlur#void
Protected
handleEscape#void
Protected
handleEscape(event: Event)
@parameventEvent
handleFocus#void
Protected
handleMouseEnter#void
Protected
handleMouseLeave#void
Protected
hide#void

Hide the tooltip immediately (bypassing delay).

show#void

Show the tooltip immediately (bypassing delay).

HostBindings#

BindingExpression
[attr.aria-describedby]ariaDescribedBy()
[style.anchor-name]cssAnchorName()

HostListeners#

EventHandler
(mouseenter)mouseenter()
(mouseleave)mouseleave()
(focus)focus()
(blur)blur()
(keydown.escape)keydown.escape()