Tooltips display a brief, informative message that appears when a user interacts with an element.
import {
Tooltip,
TooltipPopup,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
<Tooltip>
<TooltipTrigger render={<Button variant="outline" />}>
Hover me
</TooltipTrigger>
<TooltipPopup>Helpful hint</TooltipPopup>
</Tooltip>;Grouping Tooltips
To group multiple tooltips so they appear instantly after the first one is opened, wrap them in TooltipProvider. The grouping logic ensures that once a tooltip becomes visible, the adjacent tooltips will be shown instantly.
<TooltipProvider>
<Tooltip>
<TooltipTrigger render={<Button variant="outline" />}>
Tooltip 1
</TooltipTrigger>
<TooltipPopup>Content 1</TooltipPopup>
</Tooltip>
<Tooltip>
<TooltipTrigger render={<Button variant="outline" />}>
Tooltip 2
</TooltipTrigger>
<TooltipPopup>Content 2</TooltipPopup>
</Tooltip>
</TooltipProvider>You can pass showArrow as true to TooltipPopup to show arrow on tooltip. By default, it is false.
You can pass side to TooltipPopup to set the side of the tooltip. By default, it is top.
You can pass sideOffset to TooltipPopup to change the offset of the tooltip. By default, it is 4.
You can control the open and close delay of the tooltip with delay and closeDelay props on TooltipTrigger component.
You can pass animationPreset to TooltipPopup to set the animation preset of the tooltip. By default, it is scale.
If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with Pure UI quickly.
asChild → render on TooltipTriggerTooltipPopup instead of TooltipContentasChild on parts, switch to the render prop<Tooltip>
<TooltipTrigger
asChild
render={<Button variant="outline" />}
>
<Button variant="outline">Hover me</Button>
Hover me
</TooltipTrigger>
<TooltipPopup>Helpful hint</TooltipPopup>
</Tooltip>