shadcn.io is not affiliated with official shadcn/ui
Tooltip examples · Content
Tooltip with Image for React
A Preview button whose tooltip shows a product photo above a title and a line of detail.
A picture identifies a product faster than its name. This React example opens a Tooltip on a Preview button with a product photo, a bold title and a line of detail. p-0 removes the content's own padding and an inner column adds p-3 around the image and the text. Use it for quick previews of products, files or thumbnails where seeing the item helps people decide whether to open it.
Preview
Installation
FAQ
When should I use tooltips with images versus other patterns?
For a glance at something before opening it. A Tooltip can't hold anything interactive, so when people might zoom, follow a link or act on the preview, use a Hover Card, which can hold a richer preview.
What image dimensions work best in tooltips?
Small enough not to cover the page: 257 by 150 pixels here, about 16:9, inside the tooltip's 320px maximum width. The image is requested at twice that size for sharp screens, and object-cover crops it to fit.
Why use p-0 on the content with p-3 on an inner div?
p-0 replaces the tooltip's own padding, which is shaped for a line of text, and the inner div sets one even p-3 around the image and the text, with gap-1 between them.
How important is alt text for images in tooltips?
Essential. The alt text, Black headphones on a yellow background, says what the photo shows for screen readers and appears if the image fails to load. Describe the product, not the word preview.
Related
- Simple TooltipAn outline button that shows a one-line
- Tooltip with Title and DescriptionA tooltip with a bold title over a short
- Tooltip with IconA Status button whose tooltip pairs a
- Image Preview Hover CardA file name that opens a card with a
- Tooltip with Keyboard ShortcutA Save button whose tooltip names the
- Tooltip on IconA round icon button with an info icon