Skip to the page
TACTILE UI

Kit part · Cards & panels · Popovers · Tooltips

Hover card

A preview that hangs from a link when the pointer rests on it or the keyboard reaches it. The popover’s card and leader, opened by a short delay and put away by leaving.

Element
[data-hover-card]
Needs
kit.css + kit.mjs
Rules
hover-card.rules.md · 5
Finishes
Aluminium · Graphite · Porcelain · Black
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts
01

Variants

Mara Voss
MV

Mara Voss

Product designer · Lode

Draws the hub’s panels and its printed legends. Left-handed, likes a 1.6 line.

Panels
38
Since
2021
Local
14:20
A person
design review
Page

Design review

Every Thursday at 10:00, in the workshop.

A page · a title and a line
MV

Mara Voss

Product designer · Lode

Draws the hub’s panels and its printed legends. Left-handed, likes a 1.6 line.

Panels
38
Since
2021
Local
14:20
Mara Voss
Above, when the page runs out
MV

Mara Voss

Product designer · Lode

Draws the hub’s panels and its printed legends. Left-handed, likes a 1.6 line.

Panels
38
Since
2021
Local
14:20
Live · a key as the trigger
02

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartTrigger at restPointer restingKeyboard focusCard out belowCard out above
Hover cardMara VossMara VossMara Voss
Mara Voss
MV

Mara Voss

Product designer · Lode

Draws the panels.

Panels
38
MV

Mara Voss

Product designer · Lode

Draws the panels.

Panels
38
Mara Voss

Graphite

PartTrigger at restPointer restingKeyboard focusCard out belowCard out above
Hover cardMara VossMara VossMara Voss
Mara Voss
MV

Mara Voss

Product designer · Lode

Draws the panels.

Panels
38
MV

Mara Voss

Product designer · Lode

Draws the panels.

Panels
38
Mara Voss
03

API

NameKindValuesWhat it does
data-hover-cardattributea card idOn the trigger (a link or a key): the card that hangs from it. The card is a block, so put it beside the trigger, never inside a paragraph.
aria-describedbyattributethe same idOn the trigger, so the card is read as its description when it gains focus.
.tui-popover.tui-hover-cardclasspopover="manual"The card: the popover’s plate and leader, 288px wide, grid of 12px.
data-side · data-alignattributeas for the popoverOn the card: where it prefers to hang, and along which edge. It flips when the page runs out.
data-open-delay · data-close-delayattribute450 · 200 (ms)On the trigger. Keyboard focus opens after 250ms.
.tui-hover-card__who · __name · __role · __text · __factsclass—A head with an avatar, a line of prose, and a row of printed facts.
showHoverCard(trigger) · hideHoverCard()functionkit.mjsOpen one now, and put the open one away.
HOVER_OPEN_MS · HOVER_FOCUS_MS · HOVER_CLOSE_MSconstant450 · 250 · 200The timings.
Focus · Escapekeyboard—A keyboard-visible focus opens it; Escape closes it and focus stays on the trigger.
Tabkeyboard—From the trigger goes into the card, which follows it in the source, if it has anything focusable.
04

Markup

<a class="tui-link" href="/people/mara"
   data-hover-card="hc-mara" aria-describedby="hc-mara">Mara Voss</a>

<!-- Straight after its trigger, so a keyboard user can go into it -->
<div class="tui-popover tui-hover-card" id="hc-mara" popover="manual" role="note"
     data-side="bottom" data-align="center">
  <div class="tui-hover-card__who">
    <span class="tui-avatar" role="img" aria-label="Mara Voss">…</span>
    <div><p class="tui-hover-card__name">Mara Voss</p>
         <p class="tui-hover-card__role">Product designer · Lode</p></div>
  </div>
  <p class="tui-hover-card__text">Draws the hub’s panels and its printed legends.</p>
  <dl class="tui-hover-card__facts">…</dl>
</div>
import { showHoverCard, hideHoverCard } from '/kit/kit.mjs';

// Nothing to write: import kit.mjs and every [data-hover-card] works, now and later.
// Timing, per trigger: data-open-delay="450" data-close-delay="200" (milliseconds)

showHoverCard(trigger);   // open one yourself
hideHoverCard();          // and put it away

Needs kit.css and kit.mjs. How to install the kit.

05

Accessibility

  • It meets the three tests for content that appears on hover: it can be dismissed (Escape, without moving focus), hovered (moving onto it keeps it open) and persistent (it stays until you leave).
  • Focus opens it as hover does, and only keyboard-visible focus counts, so clicking with a mouse does not pop it.
  • The trigger points at the card with aria-describedby, so a screen reader reads the card as the link’s description; the card is role="note" and holds words, not controls.
  • Nothing lives only in the card. It repeats what the link’s page says; on a touch screen, which cannot hover, a tap simply follows the link.
  • With reduced motion the card appears without its small drop.
06

How it’s built

The card is the popover’s (its plate, its 12px corners, its leader running to the trigger) set with popover="manual" so the browser puts it in the top layer without any light-dismiss of its own. hover-card.mjs owns the timing: a rest of 450ms opens it, and leaving starts a 200ms grace that crossing to the card cancels, so the gap of the leader can be walked. placePopover, the popover’s own arithmetic, chooses the side and slides it to stay inside the window; it follows scrolling and resizing. One card is out at a time.

07

Rules

hover-card.rules.mdIn the brain

A glance at who or what a link is, for people who would rather not leave the page yet.

5 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

08

Reserve

Kept for a power cut.

Popover

A card hung from the key that opened it, with a printed leader running back to the key. Not modal: the page stays live around it.

AOAda OkaforSound engineer
Sessions
128
Rating
4.9

Profile card

A person’s ID plate: their coin set in a countersunk socket, name and role, a rating plate of facts engraved in tabular figures, and one key to act. Compact for one line.

Tooltip

A one-line name for an icon key, printed on a small dark plate above it on hover and on keyboard focus.

Docs
Finish
Volume