UI.MD

Tooltip

A popup that displays additional information when hovering over a trigger element.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/tooltip.json

Usage

import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"

Examples

Default

A short label for a control whose job is not obvious from its icon. It only appears on hover and focus, so never put anything in it that a touch user needs.

Positioning

Control where the tooltip shows with side (top/right/bottom/left) and align (start/center/end) on TooltipContent; both pass straight through to Base UI's positioner. Pick a cell and the code below updates to match your selection.

Tooltip placement

side="top" align="center"

API Reference

PropTypeDefaultDescription
sideTooltipContent"top" | "right" | "bottom" | "left""top"Preferred edge of the trigger to render against.
alignTooltipContent"start" | "center" | "end""center"Alignment against the trigger along the chosen side.
sideOffsetTooltipContentnumber6Distance in pixels between the tooltip and the trigger.
collisionAvoidanceTooltipContentCollisionAvoidance{ fallbackAxisSide: "end" }Object controlling how the tooltip avoids viewport collisions on the side and alignment axes, e.g. { side: 'none', align: 'none' } to always honor side/align.
delayTooltipnumber200Dwell time in ms before the tooltip opens on hover. Mount one TooltipProvider near your app root: its delay applies site-wide, and it forms the skip-delay group, so the next tooltip you hover within 400ms opens instantly. Without a Provider each Tooltip becomes its own group and pays the full delay every time.