Skip to content

Tooltip

Add to library
<button class="btn btn-outline" id="save">Save</button>
<div class="tooltip" popover="manual" data-pk-anchor="#save" data-pk-placement="top">
Add to library
</div>

The tooltip is pointed at its trigger with data-pk-anchor, and partialkit connects the two with aria-describedby. It opens on hover or focus after a short pause, and closes on leave, blur, Escape, or the click it was describing.

AttributeMeaning
popover="manual"Required: an auto popover would close whatever menu is already open
data-pk-anchorSelector for the trigger
data-pk-placementA side — top, bottom, left, right — centred on the trigger, or with -start / -end to align to an edge
data-pk-delayMilliseconds before it opens. Defaults to 600
Top
Start
End
Bottom

Keys inside a tooltip use Kbd, which picks up the dark surface on its own.

New document N
Opens straight away
Waits 1.2 seconds

A tooltip is a label you cannot interact with: no links, no buttons, no selectable text. A popover holds content people act on. If it contains anything clickable, it is a popover.

Set dir="rtl" on the page or on any subtree — the side placements follow the reading direction. See the button page for a live example.

  • The trigger is described by the tooltip, through aria-describedby. That is what makes the text reach a screen reader — the panel itself is never focused.
  • An icon-only button still needs a name. A tooltip is a description, not a label: keep the .sr-only text inside the button.
  • Focus opens it too. A keyboard user gets the same hint as a mouse user, which is why the trigger listens for focus and not only pointerenter.
  • Escape dismisses it while the trigger keeps focus, so a tooltip covering the page can be got rid of without moving.
  • popover="manual", always. Auto popovers dismiss each other; a tooltip appearing over an open menu must not close it.