shadcn.io is not affiliated with official shadcn/ui
Tooltip examples · Standard
Tooltip with Longer Text for React
A tooltip whose two-sentence message wraps onto several lines.
A one-word label isn't always enough. This React example shows a two-sentence message in a Tooltip that wraps onto several lines: the tooltip content caps its width at max-w-xs (320px), so long text breaks into short, readable lines instead of stretching across the screen. Use it for a field definition, a warning or a short onboarding hint that needs a sentence or two.
Preview
Installation
FAQ
When should I use longer multi-line tooltips?
When a control needs a sentence or two of explanation that would clutter the page if it were always visible. Past two or three sentences, use a Popover, which opens on click and stays open while people read.
Why use max-w-xs for longer tooltip text?
It is built in: the tooltip content has max-w-xs (320px), about 50 to 60 characters per line, so you don't add anything to make text wrap. Pass another max-w-* class to the content to change it.
How do I ensure longer tooltips remain readable?
Keep sentences short and plain, lead with the point and leave out jargon. If it takes more than a few seconds to read, it is too long for a Tooltip.
Should I use popovers instead of longer tooltips?
Yes, when the content has links, buttons, inputs or formatting, or when people need to keep it open while they work. A Tooltip is read once and disappears; a Popover is opened on purpose and closed when people are done.
Related
- Simple TooltipAn outline button that shows a one-line
- Tooltip PositionsFour buttons whose tooltips open on the
- Tooltip with Title and DescriptionA tooltip with a bold title over a short
- Tooltip on IconA round icon button with an info icon
- Simple Text PopoverA button that opens a popover with a
- Tooltip with IconA Status button whose tooltip pairs a