Hover Card
A hover-triggered preview card for link previews and user cards. It is a compound family composed over the shared Dropdown Panel base, so hover intent, the hover bridge that keeps the card open while the pointer travels onto it, dismissal and the keyboard model all come from the web component. Nothing in the piece schedules a timer or listens on the document.
A hover card is supplementary by design. Never put content that is only available here — anything critical belongs in the normal document flow. Use Popover for interactive, must-reach content.
Ada Lovelace
Works on the compiler and the runtime.
Joined June 2019 · 412 commits
Installation
Copy the family into your app. It pulls the shared dropdown-panel base along with it:
puzzle add piece hover-card
That base has a runtime dependency — the web component it wraps:
npm install @magic-spells/dropdown-panel
Then merge its stylesheets into your app's style entry. The first is required; the second adds the entrance effects and the drawn trigger arrow:
/* app/styles/styles.css */ @import "tailwindcss"; @import "@magic-spells/dropdown-panel/css" layer(components); /* required */ @import "@magic-spells/dropdown-panel/css/effects" layer(components); /* optional */
Requires the pieces.css tokens merged into your app styles (see Introduction).
Usage
import HoverCard from '@/components/ui/HoverCard';
<HoverCard>
<HoverCard.Trigger>@ada</HoverCard.Trigger>
<HoverCard.Content>
…profile preview…
</HoverCard.Content>
</HoverCard>The trigger element itself is the control — the component gives it role="button" and a tab stop. A real link inside still navigates (the component leaves an interactive descendant's activation alone), at the cost of a second tab stop; do that only when the preview hangs off a link that must navigate.
trigger="hover" falls back to click where (hover: hover) does not match, so the card is still reachable on a phone.
Delays
Compile pieces path-preserving
Merged two days ago into release/0.7.0.
Wrap the dropdown family
Open, awaiting review.
Right alignment
41.2 GB of 100 GB
Counted across every project in the workspace, refreshed hourly.
Reference
HoverCard
openDelayMilliseconds of hover intent before the card shows. Defaults to 600.closeDelayMilliseconds of grace after the pointer leaves. Defaults to 300.openOptional-controlled and edge-triggered. Omit it and the component owns its own state.effect'fade' | 'slide' | 'scale' | 'blur' | 'swing'. Needs the effects stylesheet.classMerged onto the dropdown component host.@show / @hideFired when THIS card opens or closes.HoverCard.Trigger
variant'link' (default) — underlined inline text, the @mention shape. 'plain' inherits the surrounding type.classMerged onto the trigger, after the variant chrome.HoverCard.Content
align'start' (default) | 'end'.opens'down' (default) | 'right'.effect'fade' | 'slide' | 'scale' | 'blur' | 'swing'. Needs the effects stylesheet.classMerged onto the panel. Merging is not precedence: use the ! suffix (mt-1!) to override a default. Never overflow-hidden.