import { KbqTitleModule } from '@koobiq/components/title';Shows a tooltip with the full text of the host element, but only when that text is truncated — i.e. it overflows horizontally, or vertically when clamped to several lines. The tooltip opens on hover and on keyboard focus, and hides on blur, mouse leave, or a resize of the measured container.
By default, the tooltip content is the trimmed textContent of the host. Provide explicit content
with [kbq-title]="stringOrTemplateRef". For nested markup, mark the measured container with the
#kbqTitleContainer template reference and the text element(s) with #kbqTitleText; several
#kbqTitleText elements are supported and the tooltip is shown when any of them overflows the container
or is clipped by its siblings.
Host components that provide KBQ_TITLE_TEXT_REF (e.g. KbqOption) supply the text and parent
elements automatically, so the directive works without explicit template references.
@Directive({ selector: '[kbq-title]', exportAs: 'kbqTitle' })
class KbqTitleDirective extends KbqTooltipTrigger {
readonly titleContent = input<TemplateRef<unknown> | string>('', {
alias: 'kbq-title'
});
readonly ignoreTooltipPointerEvents = input<boolean>(true);
readonly forDisabledComponent = input<Record<'disabledSignal', WritableSignal<boolean>>>();
readonly singleInstance = input<boolean>(
inject(KBQ_TOOLTIP_SINGLE_INSTANCE_DEFAULT),
{ alias: 'kbqTooltipSingleInstance' }
);
hideWithTimeout = input<boolean | undefined>();
trigger: string;
get isOverflown(): boolean;
get viewValue(): string;
tooltipVisible: boolean;
tooltipPlacement: KbqPopUpPlacementValues;
relativeToPointer: boolean;
relativeToCaret: boolean;
relativeToCaretVertical: KbqCaretVerticalAnchor;
tooltipPlacementPriority: string | string[] | null;
content: string | TemplateRef<unknown>;
disabled: boolean;
enterDelay: number;
leaveDelay: number;
customClass: string;
context: unknown;
color: KbqComponentColors | string;
arrow: boolean;
arrowCentered: 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;
}kbq-titleTemplateRef<unknown> | string Optional explicit tooltip content. Accepts a TemplateRef (rendered as rich tooltip content) or a string.
When omitted (a bare kbq-title attribute resolves to an empty string), the directive falls back to the
trimmed textContent of the host (viewValue), preserving the default behavior.
ignoreTooltipPointerEventsboolean Overrides the tooltip's hoverable default, as KbqOptionTooltip does. The hint spells out text that
the host had to truncate, so it floats over the neighbouring content — and a pointer-capturing pane
would swallow the clicks meant for it.
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.
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.
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.
triggerstring kbqTrigger is a single input alias shared by the tooltip, the popover and this directive, so a host
carrying both kbq-title and kbqPopover feeds one value to both. The title tooltip ignores it and
always behaves as hover + keyboard focus; the setter exists only so such a host keeps working.
Unifying the alias family is a breaking change owned by the pop-up base, not a title-local fix.
isOverflownboolean Whether the host content is clipped and therefore needs a tooltip. Returns true if any measured
text element overflows the parent — covering multiple #kbqTitleText elements, the sub-pixel
special case, and both horizontal and vertical overflow — or, with several text elements, if one of
them clips its own content.
viewValuestring Trimmed textContent of the measured parent, used as the default tooltip content.
tooltipVisibleboolean Input (kbqVisible) that programmatically shows or hides the tooltip; reflects the current visible state.
tooltipPlacementKbqPopUpPlacementValues Input (kbqPlacement) that sets the tooltip placement relative to its trigger; reflects the current placement.
relativeToPointerboolean Positions the tooltip relative to the mouse cursor. Only available for top and bottom kbqPlacement. Does not work with kbqPlacementPriority.
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.
relativeToCaretVerticalKbqCaretVerticalAnchor What the tooltip is vertically anchored to while kbqRelativeToCaret is enabled.
tooltipPlacementPrioritystring | string[] | null Input (kbqPlacementPriority) that sets the ordered fallback placements; reflects the current placementPriority.
contentstring | TemplateRef<unknown> Input (kbqTooltip) with the tooltip content — a string or a template. Updating it refreshes an open tooltip.
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.
enterDelaynumber Input (kbqEnterDelay) — delay in milliseconds before the tooltip is shown. Defaults to 400.
leaveDelaynumber Input (kbqLeaveDelay) — delay in milliseconds before the tooltip is hidden. Defaults to 0.
customClassstring Input (kbqTooltipClass) with an extra CSS class applied to the tooltip; updating it refreshes the class map.
contextunknown Input (kbqTooltipContext) with the context object passed to a template tooltip; updating it refreshes the open tooltip.
colorKbqComponentColors | string Input (kbqTooltipColor) with the tooltip color theme. Defaults to KbqComponentColors.Contrast.
arrowboolean Input (kbqTooltipArrow) — whether to render the tooltip's arrow/pointer. Defaults to false.
arrowCenteredboolean Input (kbqTooltipArrowCentered) — centers the arrow on the trigger while preserving the panel placement.
Requires a visible arrow. Defaults to false.
offsetnumber | null Input (kbqTooltipOffset) — distance in pixels between the tooltip and its trigger. null keeps
the gap of the stylesheet. Defaults to the offset of KBQ_TOOLTIP_DEFAULT_OPTIONS, when a
provider in scope set one. Inside a provider scope such as the navbar's, null/undefined restores
that inherited default.
placementChangeEventEmitter<KbqPopUpPlacementValues> Output (kbqPlacementChange) that emits the new placement whenever the tooltip repositions.
visibleChangeEventEmitter<boolean> Output (kbqVisibleChange) that emits when the tooltip's visibility changes.
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).
headerstring | TemplateRef<unknown> Header text or template, rendered above the tooltip content. Only meaningful with
kbqTooltipModifier="extended". Replaces the removed KbqExtendedTooltipTrigger.header.
isOpenboolean Whether the pop-up overlay is currently open.
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.
openedChangeObservable<boolean> Emits true when the pop-up opens and false when it closes. Part of the KbqSiblingPopup contract.
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()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()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()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()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.