Hover Card
A card on a resting pointer or on focus: a person's profile on their name, a page's title, description and image on its link. Delays before opening and closing so you can move into it and click.
The decision inside it
Extra, never the only way
It does not open on touch, where there is no hover, and focus stays on the trigger. Anything essential belongs on the page; the card is a preview.
When to use it
Use Hover Card to preview what a link or name leads to without leaving the page: a profile, a document, a URL. It opens on hover or focus, never on touch. For an action menu use Popover or Dropdown Menu.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Layro's Hover Card for this.
Install it: npx shadcn@latest add @layro/hover-card
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/hover-card.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @layro registry with your CLI token: see the Namespaced tab.
Usage
import { HoverCard } from "@/components/ui/hover-card";
export function DocsLink() {
return (
<HoverCard
trigger={<a href="https://madgixs.com/docs">our docs</a>}
url="https://madgixs.com/docs"
preview={{ title: "Madgixs docs", description: "Send, sign and store contracts.", domain: "madgixs.com" }}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
triggerrequired | React.ReactElement | The element that opens it: a link, a name, a button. Must be focusable. |
content | React.ReactNode | Your own card. Wins over `preview`. |
url | string | The link being previewed. |
preview | LinkPreviewData | The page's title, description and image, fetched on your server. |
openDelay | number | Milliseconds before it opens. Default 500. |
closeDelay | number | Milliseconds before it closes once the pointer leaves. Default 200. |
side | "top" | "bottom" | "left" | "right" | Which side of the trigger. Default bottom. |
width | number | Card width in pixels. Default 320. |
open | boolean | Controlled open state. |
onOpenChange | (open: boolean) => void | — |
className | string | — |
Dependencies
npm packages
@radix-ui/react-popoverclsxlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themeStates
All of them are drawn by the component. None is left for you to design.
- Closed
- Link preview
- Profile card
- Focus opened
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.