Skip to content

Tooltip

Contextual hints on hover and focus with positioning, collision handling, and safe pointer paths to interactive content.

<pe-tooltip>
<button type="button" class="Trigger" data-tooltip-trigger>Save</button>
<span class="Popup" data-tooltip-content hidden>
  <span class="Arrow" data-tooltip-arrow></span>
  Saves this draft without publishing.
</span>
</pe-tooltip>

Tooltip shows brief supplementary information on hover or focus. Keep tooltip content short and non-interactive; it must not replace a visible label. Keep hidden on authored content.

Give the host an id to use external or shared triggers:

<button type="button" data-tooltip-trigger="publish-tip">Publish</button>
<pe-tooltip id="publish-tip" data-tooltip-side="bottom">
<span data-tooltip-content hidden>
Makes the current version visible to visitors.
</span>
</pe-tooltip>
Part Selector Role
Host <pe-tooltip> Lifecycle host for one content node
Trigger [data-tooltip-trigger] Shows tooltip on hover/focus; closes on click while open
Content [data-tooltip-content] Tooltip surface; gets role="tooltip"
Arrow [data-tooltip-arrow] Optional decorative direct child of content; receives positioning state and coordinates

Use the same data-tooltip-delay-group on sibling hosts to skip the opening delay while moving between them.

<div class="Toolbar">
<button class="Trigger" data-tooltip-trigger="bold-tip">Bold</button>
<button class="Trigger" data-tooltip-trigger="italic-tip">Italic</button>
</div>

<pe-tooltip
id="bold-tip"
data-tooltip-delay="400"
data-tooltip-delay-group="formatting"
data-tooltip-skip-delay="300"
>
<span class="Popup" data-tooltip-content hidden>Bold text</span>
</pe-tooltip>

<pe-tooltip
id="italic-tip"
data-tooltip-delay="400"
data-tooltip-delay-group="formatting"
data-tooltip-skip-delay="300"
>
<span class="Popup" data-tooltip-content hidden>Italic text</span>
</pe-tooltip>
NameTypeDescription
isOpenboolean (readonly)Reads whether the tooltip is currently open.
open(trigger?)voidOpens the tooltip for the given trigger or the active trigger.
close()voidCloses the tooltip.
toggle(trigger?)voidShows or hides the tooltip.
NameDescription
data-tooltip-arrowMarks the optional decorative arrow. Must be a direct child of data-tooltip-content.
data-tooltip-sidePreferred side: top | right | bottom | left. Default: top.
data-tooltip-alignAlignment along the side: start | center | end. Default: center.
data-tooltip-offsetDistance from the trigger along the side axis in pixels. Default: 8.
data-tooltip-align-offsetOffset along the alignment axis in pixels. Default: 0.
data-tooltip-collision-paddingViewport padding used for flip/clamp calculations. Default: 4.
data-tooltip-arrow-paddingMinimum distance between an authored arrow and the content edges. Default: 5.
data-tooltip-delayMilliseconds to wait before opening on hover. Default: 0. Focus and programmatic open are immediate.
data-tooltip-close-delayMilliseconds to wait before closing after hover leave, content leave, or blur. Default: 0.
data-tooltip-delay-groupShared group id for sibling tooltips. Only one tooltip in a group stays open at a time.
data-tooltip-skip-delayMilliseconds after a group tooltip opened during which sibling hover opens skip data-tooltip-delay. In a delay group, leave also waits at least this long unless data-tooltip-close-delay is larger. Default: 0.
data-stateOn host/content, arrow, and triggers: "open" or "closed". With shared triggers, only the active trigger is open.
data-side / data-alignResolved side and align on content and arrow after collision handling — useful for styling.
data-uncenteredPresent on the arrow when edge padding prevents it from centering on the trigger.
NameDescription
pe-tooltip:openFired when the tooltip opens. detail includes content, trigger, and reason.
pe-tooltip:closeFired when the tooltip closes. detail includes content, trigger, and reason.

Event reasons in detail.reason: hover, focus, trigger, escape, programmatic.

Hide closed content in your base CSS:

.Popup:not([data-state="open"]) {
display: none;
}

Positioned tooltips use position: fixed on the content element while open. Style .Popup directly — borders, typography, and shadows are entirely yours.

An optional [data-tooltip-arrow] must be a decorative direct child of the content. Set its size, shape, and side styles in CSS; include its size in data-tooltip-offset.

While open, the content surface also receives positioning CSS variables:

Name Description
--anchor-width / --anchor-height Active trigger dimensions
--available-width / --available-height Remaining viewport space on the resolved side
--transform-origin Anchor-relative origin for enter/exit transitions

Content also receives data-starting-style and data-ending-style for enter and exit animations.