shadcn.io is not affiliated with official shadcn/ui
Tooltip examples · Standard
Simple Tooltip for React
An outline button that shows a one-line tooltip on hover and focus.
An icon or a terse label leaves people guessing what a control does. This React example puts a one-line Tooltip on an outline Button with Base UI: it opens on hover and on keyboard focus, and closes when the pointer or the focus leaves. Use it to name icon buttons, spell out abbreviated labels or add a word of context, never for information someone needs to finish a task.
Preview
Installation
FAQ
When should I use tooltips versus other help patterns?
Use a Tooltip for a short, supplementary label, a few words that clarify a control people can already see. For a longer explanation, or content with links and inputs, use a Popover, which opens on click and stays open. Anything essential belongs on the page: hover-only text is easy to miss.
How does the Button become the tooltip trigger?
The trigger and the Button are one element, so there is no extra wrapper and no button nested in a button.
TooltipTrigger renders the Button through render, with the label as its children.
How long should tooltips remain visible on hover?
As long as the trigger is hovered or focused: the Tooltip never times out while someone is reading it. It opens without a delay by default and closes when the pointer leaves or the trigger loses focus.
Set delay and closeDelay on TooltipTrigger, or delay on the TooltipProvider.
Are basic tooltips accessible to screen readers?
It opens when the trigger gets keyboard focus and closes on Escape. The trigger still needs its own accessible name, here its visible label, because the tooltip only supplements it. Base UI does not link the text to the trigger, so don't rely on the tooltip to name or describe the control.
Related
- Tooltip PositionsFour buttons whose tooltips open on the
- 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
- Simple Text PopoverA button that opens a popover with a
- Tooltip with IconA Status button whose tooltip pairs a