shadcn.io is not affiliated with official shadcn/ui
Hover Card examples · Preview
Link Preview Hover Card for React
A link inside a sentence that opens a card previewing the article it points to.
A link inside a sentence, this article, opens a card with the article's title, a summary and its domain. Readers decide whether to follow the link without leaving the page. Use it in posts, docs and comments.
Preview
Check out this article for more information.
Installation
FAQ
What is in the card?
The article's title, a muted summary and a row with an external-link icon and example.com.
How is the inline link made the trigger?
HoverCardTrigger renders an anchor itself, so the inline link is the trigger with href and its classes set on it.
Where does the preview come from?
In the demo it is written in the file. In an app, load the page's title and description, for example from its Open Graph tags, and render them in the card.
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
- Document Preview Hover CardA file link that opens a preview card
- Product Preview Hover CardA product link that opens a card with its
- Simple Info Tooltip Hover CardA help icon beside a label that opens a
- Simple TooltipAn outline button that shows a one-line
- Event Preview Hover CardAn event name that opens a card with its
- Image Preview Hover CardA file name that opens a card with a