The Tooltip component provides lightweight hover and focus hints with Floating UI positioning. Use it for short, contextual guidance that should stay attached to a trigger element.
Import
use PUI
# or
import PUI.Popover
Basic Tooltip
Display a tooltip on hover or focus:
<.tooltip>
<.button variant="outline">Hover me</.button>
<:tooltip>This is a helpful tooltip</:tooltip>
</.tooltip>
Placement
Tooltips support four placement options:
<.tooltip placement="top">
<span>Top</span>
<:tooltip>Top tooltip</:tooltip>
</.tooltip>
<.tooltip placement="bottom">
<span>Bottom</span>
<:tooltip>Bottom tooltip</:tooltip>
</.tooltip>
<.tooltip placement="left">
<span>Left</span>
<:tooltip>Left tooltip</:tooltip>
</.tooltip>
<.tooltip placement="right">
<span>Right</span>
<:tooltip>Right tooltip</:tooltip>
</.tooltip>
Interactive Demo
Tooltip Placements
<div class="flex flex-wrap items-center gap-6">
<.tooltip placement="top">
<.button variant="outline" size="sm">Top</.button>
<:tooltip>Tooltip on top</:tooltip>
</.tooltip>
<.tooltip placement="bottom">
<.button variant="outline" size="sm">Bottom</.button>
<:tooltip>Tooltip on bottom</:tooltip>
</.tooltip>
<.tooltip placement="left">
<.button variant="outline" size="sm">Left</.button>
<:tooltip>Tooltip on left</:tooltip>
</.tooltip>
<.tooltip placement="right">
<.button variant="outline" size="sm">Right</.button>
<:tooltip>Tooltip on right</:tooltip>
</.tooltip>
</div>
Rich Tooltip
<.tooltip id="docs-rich-tooltip" placement="bottom">
<.button variant="outline">Hover for details</.button>
<:tooltip>
<div class="w-56 space-y-2">
<p class="text-sm font-medium">Tooltip content</p>
<p class="text-xs text-muted-foreground">
Tooltips can hold short, contextual guidance without taking over the layout.
</p>
</div>
</:tooltip>
</.tooltip>
Rich Content
Tooltips can contain short formatted content:
<.tooltip id="details-tooltip" placement="bottom">
<.button variant="outline">Hover for details</.button>
<:tooltip>
<div class="w-56 space-y-2">
<p class="text-sm font-medium">Tooltip content</p>
<p class="text-xs text-muted-foreground">
Keep tooltips short and contextual so they remain easy to scan.
</p>
</div>
</:tooltip>
</.tooltip>
Variants
Use the variant attribute to switch between predefined tooltip styles.
Default (Dark)
The default variant uses a dark background with light text:
<.tooltip variant="default">
<.button variant="outline">Default</.button>
<:tooltip>Dark tooltip</:tooltip>
</.tooltip>
Light
The light variant uses a white background with a border, suitable for lighter interfaces:
<.tooltip variant="light">
<.button variant="outline">Light</.button>
<:tooltip>Light tooltip</:tooltip>
</.tooltip>
Headless
Compose PUI.Tooltip.Primitive to provide all tooltip markup and classes
yourself. The parts keep the hook contract and ARIA semantics and add no
visual classes, so supply the visibility classes too:
<PUI.Tooltip.Primitive.root id="custom-tip" placement="top" class="group w-fit">
<button type="button" class="underline">Hover me</button>
<PUI.Tooltip.Primitive.content
id="custom-tip-tooltip"
class="rounded bg-zinc-950 px-3 py-1.5 text-sm text-white aria-hidden:pointer-events-none aria-hidden:opacity-0 invisible not-aria-hidden:visible not-aria-hidden:opacity-100"
>
Custom tooltip styling
</PUI.Tooltip.Primitive.content>
</PUI.Tooltip.Primitive.root>
Variants
<div class="flex flex-wrap items-center gap-6">
<.tooltip variant="default">
<.button variant="outline" size="sm">Default</.button>
<:tooltip>Dark tooltip</:tooltip>
</.tooltip>
<.tooltip variant="dark">
<.button variant="outline" size="sm">Dark</.button>
<:tooltip>Dark tooltip</:tooltip>
</.tooltip>
<.tooltip variant="light">
<.button variant="outline" size="sm">Light</.button>
<:tooltip>Light tooltip</:tooltip>
</.tooltip>
</div>
Custom Arrow Styling
Override the default arrow color with arrow_class. The arrow automatically matches the tooltip variant, but you can provide any Tailwind classes to customize it.
Note: For
variant="light", includering-1 ring-border shadow-smin yourarrow_classto keep the arrow visible on light backgrounds.
<.tooltip variant="light" arrow_class="bg-blue-500 ring-1 ring-border shadow-sm">
<.button variant="outline">Custom arrow</.button>
<:tooltip>Blue arrow on light tooltip</:tooltip>
</.tooltip>
<.tooltip variant="default" arrow_class="bg-red-500">
<.button variant="outline">Red arrow</.button>
<:tooltip>Red arrow on dark tooltip</:tooltip>
</.tooltip>
Custom Arrow
<div class="flex flex-wrap items-center gap-6">
<.tooltip variant="light" arrow_class="bg-blue-500 ring-1 ring-border shadow-sm">
<.button variant="outline" size="sm">Blue arrow</.button>
<:tooltip>Blue arrow on light tooltip</:tooltip>
</.tooltip>
<.tooltip variant="default" arrow_class="bg-red-500">
<.button variant="outline" size="sm">Red arrow</.button>
<:tooltip>Red arrow on dark tooltip</:tooltip>
</.tooltip>
<.tooltip variant="light" arrow_class="bg-emerald-500 ring-1 ring-border shadow-sm">
<.button variant="outline" size="sm">Emerald arrow</.button>
<:tooltip>Emerald arrow on light tooltip</:tooltip>
</.tooltip>
</div>
API Reference
Tooltip Attributes
| Name | Type | Default | Description |
|---|---|---|---|
id |
string |
auto-generated | Unique identifier |
placement |
string |
"top" |
Position: "top", "bottom", "left", "right" |
variant |
string |
"default" |
"default", "light", or "dark" |
arrow_class |
string |
"" |
Custom CSS classes for the arrow element |
class |
string |
"" |
Additional CSS classes |
Tooltip Slots
| Name | Required | Description |
|---|---|---|
inner_block |
✓ | Trigger element |
tooltip |
✓ | Tooltip content (supports class) |