shadcn.io is not affiliated with official shadcn/ui
Tooltip examples · Standard
Tooltip Positions for React
Four buttons whose tooltips open on the top, the bottom, the left and the right.
A tooltip that opens over the thing someone is working on gets in the way. This React example shows the four sides a Tooltip can open on, one button each, all from the same component with Base UI doing the positioning. The Tooltip flips to the opposite side when there is no room, so a pinned side never pushes it off screen. Use it for toolbars near an edge, table actions and navigation items.
Preview
Installation
FAQ
When should I specify tooltip side positioning?
When the default would cover something people need to see, or the trigger sits near an edge: bottom for a toolbar at the top of the page, right for a sidebar on the left. Leave it unset for most triggers.
Set side on TooltipContent, for example bottom.
What is the default tooltip position if side is not specified?
The top: the Tooltip opens above its trigger and centers on it.
How does automatic collision detection work with side?
When the Tooltip would overflow the viewport on the side you chose, it flips to the opposite side and shifts along the edge to stay visible. Scroll the trigger toward an edge to see it flip.
Can I control tooltip alignment along the side?
Yes, it is centered by default and can align with the start or the end of the trigger.
Set align to start, center or end on TooltipContent.
Related
- Simple TooltipAn outline button that shows a one-line
- Tooltip with Longer TextA tooltip whose two-sentence message
- Tooltip on IconA round icon button with an info icon
- Tooltip with Title and DescriptionA tooltip with a bold title over a short
- Tooltip with IconA Status button whose tooltip pairs a
- Tooltip with ImageA Preview button whose tooltip shows a