import { KbqToolTipModule } from '@koobiq/components/tooltip';

KbqTooltipComponent

componentСкопировать ссылку на KbqTooltipComponent
@Component({ selector: 'kbq-tooltip-component' })
class KbqTooltipComponent extends KbqPopUp {
prefix: string;
get elementRef(): ElementRef<HTMLElement>;
readonly destroyRef: DestroyRef;
readonly hovered: Signal<boolean>;
trigger: KbqPopUpTrigger<unknown>;
header: string | TemplateRef<unknown>;
content: string | TemplateRef<unknown>;
context: { $implicit: unknown } | null;
classMap: {};
arrow: boolean;
defaultPaddings: boolean;
offset: number | null;
visibility: PopUpVisibility;
visibleChange: EventEmitter<boolean>;
show(delay: number): void;
updateClassMap(
placement: string,
customClass: string,
{ modifier }: { modifier: KbqEnumValues<TooltipModifier> }
): void;
isTemplateRef(value: any): boolean;
hide(delay: number): void;
isVisible(): boolean;
afterHidden(): Observable<void>;
detectChanges(): void;
}
elementRefСкопировать ссылку на elementRefElementRef<HTMLElement>

The tooltip panel, which the base pop-up measures and decorates instead of the host.

hoveredСкопировать ссылку на hoveredSignal<boolean>

Whether the pointer is over the pop-up.

classMapСкопировать ссылку на classMap{}

CSS classes of the pop-up element: the placement, the custom class and the modifiers of the subclass.

visibilityСкопировать ссылку на visibilityPopUpVisibility

Stage of the pop-up's life: not shown yet, visible, or hidden.

hide()Скопировать ссылку на hide()void

Hides the popup after a specified delay.

The hide timeout triggers the hiding of the popup by updating visibility and emitting relevant events.

Parameters
delaynumber

The delay in milliseconds before hiding the popup.

afterHidden()Скопировать ссылку на afterHidden()Observable<void>

Returns an observable that notifies when the tooltip has been hidden from view.

KbqTooltipTrigger

directiveСкопировать ссылку на KbqTooltipTrigger

Trigger directive that shows a KbqTooltipComponent for its host element. Extends KbqPopUpTrigger with tooltip-specific inputs (content, placement, color, arrow, enter/leave delays, modifier and header) and behavior such as opening on keyboard focus only and positioning relative to the mouse cursor.

@Directive({ selector: '[kbqTooltip]', exportAs: 'kbqTooltip' })
class KbqTooltipTrigger extends KbqPopUpTrigger<KbqTooltipComponent> implements KbqExclusiveTooltip {
readonly forDisabledComponent = input<Record<'disabledSignal', WritableSignal<boolean>>>();
readonly ignoreTooltipPointerEvents = input<boolean>(false);
readonly singleInstance = input<boolean>(
inject(KBQ_TOOLTIP_SINGLE_INSTANCE_DEFAULT),
{ alias: 'kbqTooltipSingleInstance' }
);
hideWithTimeout = input<boolean | undefined>();
tooltipVisible: boolean;
tooltipPlacement: KbqPopUpPlacementValues;
relativeToPointer: boolean;
relativeToCaret: boolean;
relativeToCaretVertical: KbqCaretVerticalAnchor;
tooltipPlacementPriority: string | string[] | null;
content: string | TemplateRef<unknown>;
disabled: boolean;
enterDelay: number;
leaveDelay: number;
trigger: string;
customClass: string;
context: unknown;
color: KbqComponentColors | string;
arrow: boolean;
offset: number | null;
readonly placementChange: EventEmitter<KbqPopUpPlacementValues>;
readonly visibleChange: EventEmitter<boolean>;
modifier: KbqEnumValues<TooltipModifier>;
header: string | TemplateRef<unknown>;
isOpen: boolean;
get isAttached(): boolean;
get openedChange(): Observable<boolean>;
show(delay?: number): void;
hide(delay?: number): void;
showForMouseEvent(event: MouseEvent): void;
showForElement(element: HTMLElement): void;
updateOrigin(origin: KbqOverlayOrigin | null): void;
}
forDisabledComponentinputСкопировать ссылку на forDisabledComponentRecord<'disabledSignal', WritableSignal<boolean>>

Input for controlling the disabled state of a component.

The input expects a component containing disabledSignal property, which is a writable signal emitting boolean values.

ignoreTooltipPointerEventsinputСкопировать ссылку на ignoreTooltipPointerEventsboolean

Determines whether pointer events should be ignored on tooltips.

When set to true, the tooltip pane does not receive pointer events, so clicks and hovers pass through to whatever is underneath it. Defaults to false, which keeps the tooltip hoverable: a user who needs more time to read it — or who reads at high magnification, where the pointer often ends up over the tooltip itself — can move the pointer onto it without it disappearing (WCAG 1.4.13 "Content on Hover").

Set it to true for tooltips that float over other click targets, such as the overflow hints of a scrolling option list.

kbqTooltipSingleInstanceinputСкопировать ссылку на kbqTooltipSingleInstanceboolean

Whether the tooltip takes part in the "only one tooltip is visible at a time" group: showing it hides the previously visible tooltip, and it is hidden when another tooltip is shown.

Defaults to true; the default can be changed application-wide with the KBQ_TOOLTIP_SINGLE_INSTANCE_DEFAULT token.

Tooltips without an interactive kbqTrigger (manual, none, …) never take part in the group, regardless of this input — they are shown imperatively and are expected to stay pinned.

hideWithTimeoutinputСкопировать ссылку на hideWithTimeoutboolean | undefined

Changes hiding behavior. By default, tooltip is hidden on mouseleave from trigger. Setting hideWithTimeout to true will delay tooltip hiding and will not hide when the mouse moves from trigger to tooltip.

tooltipVisibleСкопировать ссылку на tooltipVisibleboolean

Input (kbqVisible) that programmatically shows or hides the tooltip; reflects the current visible state.

tooltipPlacementСкопировать ссылку на tooltipPlacementKbqPopUpPlacementValues

Input (kbqPlacement) that sets the tooltip placement relative to its trigger; reflects the current placement.

relativeToPointerСкопировать ссылку на relativeToPointerboolean

Positions the tooltip relative to the mouse cursor. Only available for top and bottom kbqPlacement. Does not work with kbqPlacementPriority.

relativeToCaretСкопировать ссылку на relativeToCaretboolean

Positions the tooltip relative to the text caret of the field it is attached to, following it while the user types, moves the caret and scrolls the field. Anchors to the selection whenever there is one.

Every placement is available, unlike with kbqRelativeToPointer: the caret is anchored as a rectangle, so the usual fallback placements keep the tooltip on screen. Wins when both inputs are enabled.

The field is the host element itself when it is editable, otherwise the first editable it wraps.

relativeToCaretVerticalСкопировать ссылку на relativeToCaretVerticalKbqCaretVerticalAnchor

What the tooltip is vertically anchored to while kbqRelativeToCaret is enabled.

tooltipPlacementPriorityСкопировать ссылку на tooltipPlacementPrioritystring | string[] | null

Input (kbqPlacementPriority) that sets the ordered fallback placements; reflects the current placementPriority.

contentСкопировать ссылку на contentstring | TemplateRef<unknown>

Input (kbqTooltip) with the tooltip content — a string or a template. Updating it refreshes an open tooltip.

disabledСкопировать ссылку на disabledboolean

Input (kbqTooltipDisabled) controlling whether the tooltip is disabled; setting it to true hides it. undefined leaves the decision to the trigger, like an unset input.

Reads back the effective state, which for triggers that derive one of their own (see derivedDisabledWins) is not necessarily the value that was written.

enterDelayСкопировать ссылку на enterDelaynumber

Input (kbqEnterDelay) — delay in milliseconds before the tooltip is shown. Defaults to 400.

leaveDelayСкопировать ссылку на leaveDelaynumber

Input (kbqLeaveDelay) — delay in milliseconds before the tooltip is hidden. Defaults to 0.

triggerСкопировать ссылку на triggerstring

Input (kbqTrigger) with the comma-separated trigger events. An empty value resets to hover + focus and rebinds listeners.

customClassСкопировать ссылку на customClassstring

Input (kbqTooltipClass) with an extra CSS class applied to the tooltip; updating it refreshes the class map.

contextСкопировать ссылку на contextunknown

Input (kbqTooltipContext) with the context object passed to a template tooltip; updating it refreshes the open tooltip.

colorСкопировать ссылку на colorKbqComponentColors | string

Input (kbqTooltipColor) with the tooltip color theme. Defaults to KbqComponentColors.Contrast.

arrowСкопировать ссылку на arrowboolean

Input (kbqTooltipArrow) — whether to render the tooltip's arrow/pointer. Defaults to false.

offsetСкопировать ссылку на offsetnumber | null

Input (kbqTooltipOffset) — distance in pixels between the tooltip and its trigger. null, the default, keeps the gap of the stylesheet.

placementChangeСкопировать ссылку на placementChangeEventEmitter<KbqPopUpPlacementValues>

Output (kbqPlacementChange) that emits the new placement whenever the tooltip repositions.

visibleChangeСкопировать ссылку на visibleChangeEventEmitter<boolean>

Output (kbqVisibleChange) that emits when the tooltip's visibility changes.

modifierСкопировать ссылку на modifierKbqEnumValues<TooltipModifier>

Visual variant of the tooltip. Accepts 'default' | 'warning' | 'extended'. Replaces the removed KbqWarningTooltipTrigger and KbqExtendedTooltipTrigger subclasses — to render a warning tooltip use kbqTooltipModifier="warning", and kbqTooltipModifier="extended" for the extended variant (combine with kbqTooltipHeader).

headerСкопировать ссылку на headerstring | TemplateRef<unknown>

Header text or template, rendered above the tooltip content. Only meaningful with kbqTooltipModifier="extended". Replaces the removed KbqExtendedTooltipTrigger.header.

isOpenСкопировать ссылку на isOpenboolean

Whether the pop-up overlay is currently open.

isAttachedСкопировать ссылку на isAttachedboolean

Whether the pop-up overlay is currently attached.

Unlike isOpen, which follows the visibility of the pop-up component and therefore lags a task behind show()/hide(), this flips synchronously — it is the window during which the overlay (and its backdrop) is present in the DOM. Part of the KbqSiblingPopup contract.

openedChangeСкопировать ссылку на openedChangeObservable<boolean>

Emits true when the pop-up opens and false when it closes. Part of the KbqSiblingPopup contract.

show()Скопировать ссылку на show()void

Shows the tooltip after delay ms. Suppresses showing while a pop-up on the same element holds the anchor or on a focus trigger that did not originate from the keyboard, and applies cursor-relative positioning when relativeToPointer is enabled.

hide()Скопировать ссылку на hide()void

Hides the tooltip after delay ms and, when the user has genuinely left the host, un-mutes a tooltip that a pop-up on the same element had muted.

mouseleave and blur are the release signals because the base class binds hide to both regardless of whether the tooltip is currently visible. A pop-up that is still attached does not count: its backdrop steals the hover from the trigger while the pointer stands still, and that mouseleave must not be mistaken for the user leaving.

showForMouseEvent()Скопировать ссылку на showForMouseEvent()void

Shows the tooltip next to the cursor position of the given mouse event, anchoring it to the event's currentTarget instead of the directive's own host element.

Use it when the trigger cannot be declared in the template — for instance for a tooltip shared by the cells of a virtualized table. The directive still has to be created in an injection context.

showForElement()Скопировать ссылку на showForElement()void

Shows the tooltip anchored to the given element instead of the directive's own host element.

Use it when the trigger cannot be declared in the template. The directive still has to be created in an injection context:

const tooltip = runInInjectionContext(injector, () => new KbqTooltipTrigger());
tooltip.showForElement(element);

Does nothing while the tooltip is disabled or has no content — there is no overlay to anchor then.

updateOrigin()Скопировать ссылку на updateOrigin()void

Positions the pop-up against origin — an element, or a rectangle in viewport coordinates such as the one kbqCreateCaretOrigin keeps on the caret — instead of the host element; null restores the host element. An open pop-up moves to the new origin at once.

This moves the position origin only. setExternalNativeElement moves the host itself, and with it the trigger's event listeners, its focus target and the scroll containers the pop-up follows.

KbqTooltipDelayTracker

serviceСкопировать ссылку на KbqTooltipDelayTracker

Remembers when a tooltip was last shown, so that moving between neighbouring triggers does not replay the enter delay for every one of them: the first tooltip waits kbqEnterDelay, the ones following it within KBQ_TOOLTIP_INSTANT_SHOW_WINDOW appear instantly.

Application-wide by design — the behavior is part of the component's documented delay rules.

@Injectable({ providedIn: 'root' })
class KbqTooltipDelayTracker {
shouldSkipEnterDelay(): boolean;
markShown(): void;
reset(): void;
}
shouldSkipEnterDelay()Скопировать ссылку на shouldSkipEnterDelay()boolean

Whether the tooltip that is about to be shown should skip its enter delay.

markShown()Скопировать ссылку на markShown()void

Records that a tooltip has just been shown.

reset()Скопировать ссылку на reset()void

Forgets the last shown tooltip, so the next one appears with its full enter delay.

KbqTooltipRegistry

serviceСкопировать ссылку на KbqTooltipRegistry

Keeps track of the single tooltip that is currently visible, so that showing a new one hides the previous. Holds the trigger, not the overlay component — the latter is re-created on every show.

@Injectable({ providedIn: 'root' })
class KbqTooltipRegistry {
setVisible(tooltip: KbqExclusiveTooltip): void;
clearVisible(tooltip: KbqExclusiveTooltip): void;
}
setVisible()Скопировать ссылку на setVisible()void

Marks the tooltip as the only visible one, hiding the previously visible tooltip.

clearVisible()Скопировать ссылку на clearVisible()void

Clears the registry, but only when the given tooltip is still the registered one. The guard matters because hiding the previous tooltip is asynchronous: its visibleChange(false) arrives after the new tooltip has already been registered, and must not wipe that newer entry.

KbqCaretVerticalAnchor

typeСкопировать ссылку на KbqCaretVerticalAnchor

What the tooltip is vertically anchored to when it is positioned relative to the caret:

  • 'line' — the line of text the caret is on.
  • 'field' — the whole field, so the tooltip never covers it; horizontally it still follows the caret.
  • 'auto' — 'field' for a single-line <input>, 'line' for everything else.
type KbqCaretVerticalAnchor = 'auto' | 'line' | 'field';

TooltipModifier

enumСкопировать ссылку на TooltipModifier
enum TooltipModifier {
Default = 'default',
Warning = 'warning',
Extended = 'extended'
}

KBQ_TOOLTIP_INSTANT_SHOW_WINDOW

constСкопировать ссылку на KBQ_TOOLTIP_INSTANT_SHOW_WINDOW

Length in milliseconds of the window during which a tooltip shown right after another one appears instantly. Defaults to MIN_TIME_FOR_DELAY.

const KBQ_TOOLTIP_INSTANT_SHOW_WINDOW: InjectionToken<number>;

KBQ_TOOLTIP_OPEN_TIME

constDeprecatedСкопировать ссылку на KBQ_TOOLTIP_OPEN_TIME

Replaced by KbqTooltipDelayTracker, which owns the shared timestamp behind a service instead of a mutable useValue object. The tooltip no longer reads this token; providing it has no effect. Will be removed in 22.0.0.

const KBQ_TOOLTIP_OPEN_TIME: InjectionToken<{ value: number }>;

KBQ_TOOLTIP_SCROLL_STRATEGY

constСкопировать ссылку на KBQ_TOOLTIP_SCROLL_STRATEGY
const KBQ_TOOLTIP_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;

KBQ_TOOLTIP_SINGLE_INSTANCE_DEFAULT

constСкопировать ссылку на KBQ_TOOLTIP_SINGLE_INSTANCE_DEFAULT

Default value of the kbqTooltipSingleInstance input. Provide false at the application level to globally disable the "only one tooltip is visible at a time" behavior.

const KBQ_TOOLTIP_SINGLE_INSTANCE_DEFAULT: InjectionToken<boolean>;

MIN_TIME_FOR_DELAY

constСкопировать ссылку на MIN_TIME_FOR_DELAY

Default length of the window during which a following tooltip is shown without its enter delay.

const MIN_TIME_FOR_DELAY: number;
Предложения по улучшению
Если вы нашли ошибку или хотите доработать статью, создайте запрос на GitHub.