Hover card
Point at a name and wait a moment: a card opens with the name set large and cropped by its edge.
Report an issue with Hover cardExample
The work is led by Ada Lindqvist.
Everything the page says is set in a grotesque, and everything you say back in an italic.
The two faces were her choice, made in the first week.
name, open
Design director. Twelve years of identities for museums and publishers, and the reason the studio sets everything in two faces.
entry, open
noun
- A sans serif of the nineteenth century, heavier and less even than the ones that came after.
- The voice of this page.
quote, open
Two faces are enough for anything worth saying.
Install
Run it in a project that has the shadcn CLI set up. It brings the 0nlyType base along.
npx shadcn@latest add https:// thedirectors.agency/ ui/ r/hover-card.jsonUsage
import { HoverCard, HoverCardContent, HoverCardMeta, HoverCardName, HoverCardTrigger } from "@/components/ui/hover-card"function Person() {return (<><HoverCardName>Lindqvist</HoverCardName><span>Design director. Twelve years of identities for museums and publishers, and the reason the studio sets everything in two faces.</span><HoverCardMeta>Stockholm, with the studio since 2019</HoverCardMeta></>)}function Entry() {return (<><HoverCardName>gro·ˈtesque</HoverCardName><p className="ot-term">noun</p><ol><li>A sans serif of the nineteenth century, heavier and less even than the ones that came after.</li><li>The voice of this page.</li></ol><HoverCardMeta>From the Italian <span className="ot-term">grottesca</span>, the painting found on the walls of grottoes</HoverCardMeta></>)}function Quote() {return (<><blockquote>Two faces are enough for anything worth saying.</blockquote><HoverCardMeta>Ada Lindqvist, design director</HoverCardMeta></>)}export default function Example() {return (<div className="grid max-w-[34rem] gap-6"><p>The work is led by{" "}<HoverCard><HoverCardTrigger asChild><a className="ot-link" href="#hover-card">Ada Lindqvist</a></HoverCardTrigger><HoverCardContent><Person /></HoverCardContent></HoverCard>.</p><p>Everything the page says is set in a{" "}<HoverCard><HoverCardTrigger asChild><a className="ot-link" href="#hover-card">grotesque</a></HoverCardTrigger><HoverCardContent variant="entry"><Entry /></HoverCardContent></HoverCard>, and everything you say back in an italic.</p><p>The two faces were{" "}<HoverCard><HoverCardTrigger asChild><a className="ot-link" href="#hover-card">her choice</a></HoverCardTrigger><HoverCardContent variant="quote"><Quote /></HoverCardContent></HoverCard>, made in the first week.</p></div>)}// Pinned open in place: each card as Radix would open it, in the flow instead of beside a name.Contract
- Underneath: Radix HoverCard.
- Anatomy:
<span class="ot-peek"><a>Name</a><span class="ot-peek-card">holding.ot-peek-name(aria-hidden), a sentence and.ot-peek-meta. - The name, set large and cut by the card's top edge through its ascenders (and by its end, when long), slides in to meet you. It is decorative and not selectable (
user-select: none): a selection would only paint a slab of yellow across the crop. It waits 450ms for the pointer; focus shows it at once. While the card is open its trigger holds the link's highlighter (data-state="open"), black on yellow, so you can see what the card belongs to. The card's text meets 4.5:1 on its paper in every scheme and mode: the body (graphite) 7.1 to 10.6, the meta line (pencil) 4.63 (statue, day) to 5.91, the name (ink) 11.7 to 18.9; selected, 16.5. Where anchor positioning exists, the card flips or centres rather than leave the screen. - Variants go on
data-variantof the card (HoverCardContent variant): name (the default), entry, quote. - Entry, after "the uncreative": a dictionary entry for the word you point at.
HoverCardNamegiven a headword with its syllable points and stress mark (gro·ˈtesque) sets it heavy at--ot-mfand breaks it at each point with a dot (.ot-peek-point); the stressed syllable is reversed out of the ink (.ot-peek-stress, paper on ink, over 15:1). Then the part of speech in the italic (.ot-term, as dictionaries set it), the senses as an<ol>with bold figures hung in the margin, and the word's history inHoverCardMeta. The headword is decorative; the trigger is the word. - Quote, after the magazine pull quote: what the person said, as a
<blockquote>in the italic (their words, not ours) at--ot-mp, in ink. The opening mark hangs in the margin at the size of a title and the card's top edge cuts its tails, the name's crop moved to the mark. The attribution, inHoverCardMeta, is ours. - Keyboard: focus opens every variant at once. Reduced motion: the points and the mark are simply there. Right to left: the name slides the other way and the margin (the senses' figures, the mark) is on the right. Forced colours: the reversed syllable keeps its ink as a system colour pair.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
openDelay / closeDelay | number | 450 / 300 | How long a still pointer waits before the card opens, and how long it lingers. Focus opens it at once. |
HoverCardContent variant | "name" | "entry" | "quote" | "name" | name: the name set large and cut by the card's top edge and its end. entry: a dictionary entry for the word you point at: the headword heavy and broken at its syllables, the stressed one reversed out of the ink, then the part of speech (.ot-term), the senses as an <ol> numbered in the margin, and the word's history in HoverCardMeta. quote: what the person said, in a <blockquote>, set in the italic with the opening mark hung in the margin and cut by the card's edge; the attribution in HoverCardMeta. |
HoverCardContent side / align / sideOffset | Radix | "bottom" / "start" / 12 | Where the card sits. It flips rather than leave the screen. |
HoverCardName | span | The name, set large and cropped by the card's edge. Decorative; put the readable name in the trigger. Under entry, write the headword with its syllable points and stress mark ("gro·ˈtesque"): it breaks at each point and reverses the stressed syllable out of the ink. | |
HoverCardMeta | span | A last line in pencil. |
Craft
Where its move comes from
| Component | Reference | Move |
|---|---|---|
| Hover card | POINT crop | The name cut by the card's top edge |
| Entry hover card | "the uncreative"; the dictionary entry | The headword broken at its syllables, the stressed one reversed out of the ink |
| Quote hover card | The pull quote; POINT crop | Their words in the italic, the opening mark hung in the margin and cut by the edge |
How it moves
| Component | Articulation | What moves |
|---|---|---|
| Hover card | Slide | The large name slides in to meet you |
| Entry hover card | Spelling out | The headword opens at its breaks and each point lands in turn |
| Quote hover card | Spiccato | The mark drops into the margin and lands |