Component
Tooltip
Hover/focus tooltip using CSS Anchor Positioning. Zero JavaScript for positioning.
On this page
The .pl-c-tooltip wraps a trigger element and displays a tooltip body on
hover or keyboard focus. Positioning uses CSS Anchor Positioning
(anchor-name, position-anchor, position-area) with
position-try-fallbacks for collision handling.
Semantic HTML
Wrapper form (Universal anchor positioning)
<span class="pl-c-tooltip" style="--pl-c-tooltip-anchor: --tip-1;">
<span class="pl-c-tooltip__trigger">
<button aria-describedby="tip-1">Help</button>
</span>
<span class="pl-c-tooltip__body" role="tooltip" id="tip-1">
Helpful context here.
</span>
</span>
Top-layer declarative form (popover="hint" & interestfor)
In modern browsers supporting popover="hint" (Chrome 133+) and Interest Invokers (interestfor, Chrome 142+), tooltips can be hoisted to the top layer. This completely eliminates clipping from overflow containers without closing active menus or dialogs:
<button
class="pl-c-button"
interestfor="tip-metrics"
aria-describedby="tip-metrics"
style="anchor-name: --tip-metrics;"
>
Throughput
</button>
<div
popover="hint"
class="pl-c-tooltip__body"
role="tooltip"
id="tip-metrics"
style="position-anchor: --tip-metrics;"
>
Real-time cluster events over the last 24h.
</div>
Each tooltip instance needs a unique --pl-c-tooltip-anchor value.
Progressive enhancement
Without anchor positioning support, the tooltip body is hidden entirely
(@supports not (position-anchor: --x)) to avoid misleading placement.
The trigger remains fully functional via aria-describedby.
Class contract
| Selector | Role |
|---|---|
.pl-c-tooltip |
Wrapper (inline-flex, relative). |
.pl-c-tooltip__trigger |
The anchor element (anchor-name). |
.pl-c-tooltip__body |
The tooltip text (role="tooltip"). |
--pl-c-tooltip-anchor |
Unique anchor name per instance. |