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="#hover-card" id="hover-card-trigger">@partialkit</a>
<div class="hover-card" id="demo-hover-card" popover data-pk-anchor="#hover-card-trigger" data-pk-placement="bottom"> <div style="display: flex; gap: 0.75rem"> <span class="avatar"><span class="avatar-fallback">PK</span></span>
<div style="display: grid; gap: 0.25rem"> <h4 id="hover-card-title" style="margin: 0; font-size: 0.875rem; font-weight: 500">@partialkit</h4> <p style="margin: 0">Components for plain HTML — Tailwind classes and a small ESM runtime.</p> <p style="margin: 0; color: var(--muted-foreground); font-size: 0.75rem">Joined August 2026</p> </div> </div></div><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.
| Attribute | Meaning |
|---|---|
data-pk-anchor | Selector for the trigger |
data-pk-placement | A side — top, bottom, left, right — optionally with -start or -end |
data-pk-delay | Milliseconds before it opens. Defaults to 700 |
Placement
Section titled “Placement”<a class="btn btn-link" href="#hover-top" id="hover-top-trigger">Above</a><div class="hover-card" popover data-pk-anchor="#hover-top-trigger" data-pk-placement="top" data-pk-delay="150"> <p style="margin: 0">Opens above, after a shorter pause.</p></div>
<a class="btn btn-link" href="#hover-end" id="hover-end-trigger">Beside</a><div class="hover-card" popover data-pk-anchor="#hover-end-trigger" data-pk-placement="right" data-pk-delay="150"> <p style="margin: 0">Opens at the trailing edge, centred on the link.</p></div>Hover Card or Tooltip?
Section titled “Hover Card or Tooltip?”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.
Accessibility
Section titled “Accessibility”- 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
dialogrole, 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.