GUILD OF GLEKS UIv21.4.4

gogTooltip

Tooltip

A hover/focus tooltip as a directive, not a component — drop it on any element, a gog-* component's own host tag or a plain native one, and that element needs to know nothing about it.

Overview

Import the directive and put it on the trigger.

typescript
import { GogTooltipDirective } from '@guildofgleks/ui';

@Component({
  // ...
  imports: [GogTooltipDirective],
})

Basic usage — hover or tab onto either of these:

Draft
<button gogTooltip="Save changes">Save</button>

<!-- Or on a gog-* component’s own host tag — it needs to know nothing about it. -->
<gog-chip [gogTooltip]="hint">Draft</gog-chip>

Examples

Position

auto (the default) picks whichever side has room, preferring top, then bottom, then right, then left. An explicit side still flips to its opposite when the requested one has no room but the opposite does — so a tooltip near the viewport edge stays readable rather than being clipped.

<gog-button gogTooltip="Above" gogTooltipPosition="top">top</gog-button>
<gog-button gogTooltip="Below" gogTooltipPosition="bottom">bottom</gog-button>
<gog-button gogTooltip="To the left" gogTooltipPosition="left">left</gog-button>
<gog-button gogTooltip="To the right" gogTooltipPosition="right">right</gog-button>

Rich content

Pass a TemplateRef instead of a string when the bubble needs real markup.

<ng-template #richHint>
  <strong>Deployment blocked</strong>
  <p>Two checks are still running. <gog-tag variant="warning">CI</gog-tag></p>
</ng-template>

<gog-button [gogTooltip]="richHint">Deploy</gog-button>

Long content is hoverable and scrollable

Content wraps at --gog-tooltip-max-width and scrolls past --gog-tooltip-max-height inside an internal gog-scroll, so it uses the same themeable scrollbar as every other overflowing panel here. Moving the pointer from the trigger onto the bubble cancels the pending hide instead of racing it — per WCAG 2.1 SC 1.4.13.

Delays and disabling

gogTooltipShowDelay defaults to 300 ms and gogTooltipHideDelay to 100 ms — the hide gap is what gives the pointer time to travel onto the bubble. gogTooltipDisabled suppresses the tooltip without removing the directive.

<gog-button gogTooltip="Appears at once" [gogTooltipShowDelay]="0">No delay</gog-button>
<gog-button gogTooltip="Takes a second" [gogTooltipShowDelay]="1000">Slow</gog-button>
<gog-button gogTooltip="Never shown" [gogTooltipDisabled]="true">Disabled</gog-button>

App-wide defaults

Position and both delays read GOG_CONFIG.tooltip, so a house style is set once. An instance's own input always wins.

typescript
import { provideGogConfig } from '@guildofgleks/ui';

bootstrapApplication(App, {
  providers: [
    provideGogConfig({
      tooltip: {
        position: 'top',
        showDelay: 150,
        hideDelay: 100,
      },
    }),
  ],
});

Restyling one bubble

The bubble is appended to document.body, so it is never clipped by an ancestor's overflow: hidden — and so it sits outside any scoped component stylesheet. That is the same limitation gog-select's [appendToBody] panel has: gogTooltipClass applies a class to the bubble, but the rules for that class have to come from an unscoped (global) stylesheet.

Visually the bubble is the same floating-panel recipe as a dialog panel or a dropdown — surface background, plain border, panel shadow — rather than a bespoke inverted bubble, so it reads as part of a themed app instead of something dropped on top of it.

Accessibility

Shown on both mouse hover and keyboard focus, dismissible with Escape, and hoverable so a long bubble can actually be read. Focus is tracked with focusin / focusout rather than focus / blur, which keeps it replay-safe under SSR event replay.

A tooltip triggered inside a dialog stacks above it — the dialog panel raises --gog-tooltip-z the same way it raises the dropdown's.

API Reference

Inputs

NameTypeDefaultDescription
gogTooltipstring | TemplateRef<unknown> | nullnullThe bubble’s content. A plain string for the common case, or a TemplateRef for richer markup.
gogTooltipPosition'auto' | 'top' | 'bottom' | 'left' | 'right'GOG_CONFIG.tooltip.position ?? 'auto'Which side the bubble renders on. auto prefers top, then bottom, then right, then left. An explicit side still flips to its opposite if the requested one has no room but the opposite does.
gogTooltipShowDelaynumberGOG_CONFIG.tooltip.showDelay ?? 300Milliseconds of hover or focus before the bubble appears.
gogTooltipHideDelaynumberGOG_CONFIG.tooltip.hideDelay ?? 100Milliseconds before it disappears. The gap is what lets the pointer travel from the trigger onto the bubble.
gogTooltipDisabledbooleanfalseSuppresses the tooltip without removing the directive.
gogTooltipClassstring''A class applied straight to the bubble, for restyling or resizing one instance. It must come from an unscoped (global) stylesheet — the bubble lives on document.body, outside any component’s scoped styles.

Styling Tokens

Every CSS custom property the tooltip paints with. Override any of them — on a subtree or a theme — to restyle it. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.

TokenDescription
--gog-tooltip-bg / -color / -border-color / -shadow / -radiusThe bubble surface. Deliberately the same floating-panel recipe as a dialog or dropdown, not a bespoke inverted bubble.
--gog-tooltip-max-width / -max-heightContent wraps at the width and scrolls past the height, inside an internal gog-scroll.
--gog-tooltip-padding / -gap / -arrow-sizeBubble padding, its distance from the trigger, and the arrow.
--gog-tooltip-font-family / -font-size / -line-heightBubble typography.
--gog-tooltip-z / -transition-durationStacking order (raised inside a dialog so a tooltip stacks above it) and fade timing.