Skip to content

Hover Card

@partialkit
PK

@partialkit

Components for plain HTML — Tailwind classes and a small ESM runtime.

Joined August 2026

<a class="btn btn-link" href="/about" id="profile">@partialkit</a>
<div class="hover-card" popover data-pk-anchor="#profile" data-pk-placement="bottom"></div>

It opens when the pointer rests on the link, and stays open while the pointer travels into it — a preview is something you read, and sometimes click inside.

AttributeMeaning
data-pk-anchorSelector for the trigger
data-pk-placementA side — top, bottom, left, right — optionally with -start or -end
data-pk-delayMilliseconds before it opens. Defaults to 700
Above

Opens above, after a shorter pause.

Beside

Opens at the trailing edge, centred on the link.

A tooltip is a short label you cannot touch: no links, no buttons, and it closes the moment you move. A hover card is a surface — an avatar, a description, actions — that survives the trip from the link and dismisses on Escape or a click outside.

Set dir="rtl" on the page or on any subtree — the card follows the reading direction and flips when it would overflow. See the button page for a live example.

  • The trigger is a link, so it stays a link. No aria-expanded, no button role: it navigates, and the card is a preview of where it goes.
  • The card is a dialog role, labelled by its own heading when it has one. It is a surface with content, not a description of the link.
  • It opens on focus too, not only on hover, so a keyboard user reaching the link sees the same preview. Focus is never moved into it — that would trap someone tabbing through a paragraph.
  • Escape closes it, and a click outside dismisses it, both from the browser’s popover.
  • The content is a shortcut, never the only copy. Anything a person must have is behind the link as well.