Tooltip

Compact and detailed labels on hover, focus, or a viewport point.

Also known as: hover tip, focus tip, hover label, info tip

Installation

Install with the CLI, or copy the component source into your project.

Add tooltip (npm)

npx --yes -p @default-file/ui df-ui add tooltip

Compact

Compact tip for short hints kept on one-line.

Detailed: single line

Detailed panel with copy kept on one-line and truncated with an ellipsis.

Detailed: wrapping

Detailed panel with wrap enabled so longer copy flows across multiple lines.

Appearance

Compare light, dark, and inverse. inverse uses a dark tip on light pages and a light tip on dark pages.

Without arrow

Hide the pointer by setting arrow to false.

Point anchor

Anchor a controlled tip to a viewport point with no trigger. Auto-hides using --df-duration-tip-hold.

Sides

Corner placements (top left, top right, bottom left, bottom right) plus centred top, right, bottom, and left.

Properties

Compact or detailed labels on hover, focus, or a viewport point. Compose Tooltip, TooltipTrigger, and TooltipContent. Point mode uses anchorPoint and omits TooltipTrigger.

Tooltip

PropTypeDefaultNotes
variant"compact" | "detailed""compact"Content density and typography.
appearance"light" | "dark" | "inverse""inverse"Panel surface color. inverse uses a dark tip on light pages and a light tip on dark pages; light and dark lock one surface.
openboolean-Controlled open state.
defaultOpenboolean-Initial open state when uncontrolled.
onOpenChange(open: boolean) => void-Called when open state changes.
delayDurationnumber200Hover delay in milliseconds before showing.
anchorPoint{ x: number; y: number } | null-Viewport point to anchor the tip when there is no trigger. Use with controlled open.
dismissDurationnumber-Auto-hide duration in milliseconds while open. When omitted in point mode, uses --df-duration-tip-hold.

TooltipTrigger

PropTypeDefaultNotes
renderReactElement-Host element to attach tooltip behavior to.
childrenReactNode-Trigger content when not using render.

TooltipContent

PropTypeDefaultNotes
side"top" | "bottom" | "left" | "right""top"Preferred placement side. Flips when there is not enough space.
align"start" | "center" | "end""center"Alignment along the side.
sideOffsetnumber14Gap between trigger and content.
alignOffsetnumber0Shift along the alignment axis.
wrapboolean-For the detailed variant, wrap text within the max width.
arrowbooleantrueShow the pointing caret. The anchoring engine keeps it aimed at the trigger or anchor point after collision clamping.
childrenReactNode-Tooltip label or detailed body.

Tokens

Theme defaults live on :root. Override these globally or on a local host.

TokenTypeDefaultNotes
--df-tooltip-max-widthCSS length16remCompact variant max width.
--df-tooltip-max-width-detailedCSS length18remDetailed variant max width.
--df-tooltip-arrow-offsetCSS length3.5pxArrow distance from the content edge.
--df-tooltip-arrow-align-nudgeCSS length4pxHalf-caret optical nudge for the trigger-tracked caret.
--df-anchor-arrow-crossCSS length50%Trigger-centered caret offset on the cross axis. Set by the anchoring engine after collision clamping.
--df-anchor-arrow-cross-insetCSS lengthcalc(3 * var(--spacing-unit))Minimum inset that keeps the trigger-tracked caret on the panel edge.
--df-duration-tip-holdCSS time1800msDefault auto-hide duration for point-anchored tips.
--df-shadow-tooltipCSS shadowdrop-shadow(0 4px 6px rgb(0 0 0 / 0.1)) drop-shadow(0 2px 3px rgb(0 0 0 / 0.08))Drop shadow that includes the arrow silhouette.
--popoverCSS colorvar(--df-neutral-900)Tip fill. Remapped by appearance (inverse, light, or dark).
--popover-foregroundCSS colorvar(--df-neutral-0)Tip text color. Remapped by appearance.
--foregroundCSS colorvar(--df-neutral-0)Used for the tip border mix. Remapped by appearance.