shadcn.io is not affiliated with official shadcn/ui
Hover Card examples · Preview
Document Preview Hover Card for React
A file link that opens a preview card with the document's size, summary and last change.
A file link, Project Proposal.pdf, opens a preview with a file icon, the size and type, a one-line summary and the last change date. People can check they have the right document before opening it.
Preview
Installation
FAQ
What is in the card?
A file icon on a bg-destructive/10 tile, the name, 2.4 MB · PDF Document, the summary and Last modified: December 15, 2023.
How is the file link made the trigger?
HoverCardTrigger renders an anchor itself, so the file link is the trigger with href and its classes set on it.
Why is the file icon red?
Red is the usual color for PDF files. The tile uses the destructive token, bg-destructive/10 with a text-destructive icon, so it follows the theme. Pick a token per file type.
How wide is the card?
w-80 on the card, for the extra content.
The class is on HoverCardContent.
max-w-full keeps it inside narrow screens.
How do I change how fast the card opens and closes?
The card opens a moment after the pointer rests on the trigger and stays up long enough for the pointer to move into it. Both delays are in milliseconds.
The demo sets delay 10 and closeDelay 100 on HoverCardTrigger. side and align on HoverCardContent place it.
Does the card open from the keyboard and on touch screens?
Focusing the link opens the card, moving focus away or pressing Escape closes it. Touch screens have no hover, so keep what matters reachable elsewhere, or use a Popover when the card has to open on a tap.
Related
- Image Preview Hover CardA file name that opens a card with a
- Link Preview Hover CardA link inside a sentence that opens a
- Product Preview Hover CardA product link that opens a card with its
- Event Preview Hover CardAn event name that opens a card with its
- Info with Icon and Badge Hover CardA Verified badge that opens a card
- Info with Title Hover CardAn info icon beside a label that opens a