Skip to content

Components / Tooltip

Tooltip

A short, supplemental description shown on hover or keyboard focus. Square, monospaced content follows its trigger’s scoped theme, even through a body portal.

Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.

Usage playground

Hover Save draft, or focus it with Tab. Focus opens immediately; the delay applies to pointer hover. This description-only demo does not save data. Move onto the tooltip to keep reading, or press Escape to dismiss.

React / TSX
'use client';

import { Button } from "@/components/ui/yads-button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/yads-tooltip";

export default function SaveDescription() {

Installation

pnpm dlx [email protected] add biehlio/yet-another-design-system/tooltip#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40

Tooltip samples include their layout styles. Install Button separately when imported by a sample.

Run this revision-pinned command in a project configured for shadcn. It installs yads-tooltip, Radix Tooltip 1.4.1, its scoped stylesheet and JetBrains Mono. Import { Tooltip } from @/components/ui/yads-tooltip (adjust the alias to your project). No global CSS, Tailwind utilities, reset or global theme provider is required.

Copy sample includes the complete consumer module and any recipe CSS, even when collapsed. Interactive examples include a client boundary for React Server Component apps. These examples compose the separately installed YADS Button using asChild. They include their layout styles and need no consumer Tailwind. Tooltip itself does not depend on other primitives.

Controlled description

Use open and onOpenChange together. Accept dismissal requests so Escape, blur and pointer departure can close the description. For uncontrolled usage, omit open; defaultOpen only sets the initial state.

Description closed

React / TSX
'use client';

import { Button } from "@/components/ui/yads-button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/yads-tooltip";
import { useState } from 'react';

Related triggers and timing

Every Tooltip works without setup. An optional local TooltipProvider shares timing between related triggers: after one opens, nearby descriptions open immediately during skipDelayDuration. A Tooltip delayDuration overrides the provider. Keep hoverable content enabled for pointer transit.

React / TSX
'use client';

import { Button } from "@/components/ui/yads-button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/yads-tooltip";

export default function RelatedDescriptions() {

className customization

Content accepts className and style on the portaled surface. This complete border recipe preserves theme colors, wrapping and collision handling. Preferred side and alignment may change near a viewport edge.

React / TSX
'use client';

import { Button } from "@/components/ui/yads-button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/yads-tooltip";

export default function CustomDescription() {

Accessibility

  • Supplement, never replace. Give the trigger its own accessible name through visible text or an aria-label for an icon-only control. While open, Radix connects a role="tooltip" description via aria-describedby. Never put essential instructions, validation errors or the only explanation of an action here; keep those visible nearby.
  • No interactive content. Use short text only, not links, inputs or buttons. Tooltip does not move focus. Use a Dialog or another appropriate interactive pattern for actions and longer tasks.
  • Keep keyboard and pointer access. Tab opens immediately; blur, Escape, trigger click, outside pointer press, ancestor scroll and pointer departure dismiss. Pointer users can move across the gap onto content and keep reading. Do not disable hoverable content without an accessible alternative. Keyboard focus remains visible in both themes.
  • Touch is not hover. Radix ignores touch hover; do not rely on a tap or long press to expose a description. Keep necessary information visible for touch users.
  • Disabled triggers are unavailable. A native disabled button cannot receive keyboard focus and hover behavior varies by browser. Do not depend on a disabled-trigger tooltip or add a focusable wrapper just to explain it. Explain the unavailable action in persistent nearby text instead.

Content portals to the body and follows the trigger’s nearest data-theme="light|dark", .light or .dark ancestor, including live attribute changes and light islands. Standalone defaults to light; no global theme provider is required. Reduced-motion preference disables the brief fade.

API reference

Import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, type TooltipProps, type TooltipProviderProps } from @/components/ui/yads-tooltip. Root and Provider render no DOM. Props follow Radix Tooltip 1.4.1; Trigger and Content forward refs and support asChild. Content always uses a body portal; no separate Portal export or application-wide provider is needed.

On narrow screens, focus the table and scroll horizontally to read all columns.

Tooltip parts, props, types, defaults and behavior
PartPropTypeDefaultDescription
Tooltipopen / defaultOpenbooleanfalse (uncontrolled)Controlled state or initial uncontrolled state; do not combine or switch modes.
TooltiponOpenChange(open: boolean) => voidNot setOpening/dismissal request. Update controlled open in response.
TooltipdelayDurationnumber (ms)Provider value (700)Pointer hover delay. Keyboard focus opens immediately.
Tooltip / TooltipProviderdisableHoverableContentbooleanfalsetrue closes when leaving the trigger; keep false so users can move onto content to read.
TooltipProviderdelayDuration / skipDelayDurationnumber (ms)700 / 300Optional local shared hover timing; each Tooltip otherwise owns a provider. Not a theme provider.
TooltipTriggerasChildbooleanfalseRender the single child rather than a button. Child must spread props and forward its ref; works with YADS Button. Never nest buttons.
TooltipTriggerref / native propsRef<HTMLButtonElement> / native attributesNot setRef reaches the actual trigger (the child element with asChild). Native events, type, disabled, aria-* and data-* pass through. Set type="button" in forms.
TooltipContentside / aligntop | right | bottom | left / start | center | endtop / centerPreferred placement; collision handling can flip or shift it.
TooltipContentsideOffset / alignOffsetnumber (px)6 / 0Gap from trigger and alignment adjustment.
TooltipContentavoidCollisions / collisionPaddingboolean / number | partial side maptrue / 8Keep within boundary with an inset; leave enabled on narrow screens.
TooltipContentcollisionBoundary / sticky / hideWhenDetachedElement | null | array / partial | always / boolean[] / partial / falseRadix positioning boundary, sticky behavior and detached-trigger visibility.
TooltipContentasChild / forceMountboolean / truefalse / not setasChild uses one noninteractive element. forceMount retains closed content for custom animation; consumer must hide closed content correctly.
TooltipContentaria-labelstringContent textOptional alternative description text; does not name the trigger. Prefer plain meaningful content.
TooltipContentonEscapeKeyDown / onPointerDownOutsideRadix event handlersNot setDismissal events; preventDefault cancels dismissal. Avoid trapping descriptions open.
TooltipContentclassName / style / refstring / CSSProperties / Ref<HTMLDivElement>Not setForwarded to the body-portaled surface; scoped class is retained.

Styling and composition

Trigger and Content expose data-state (closed, delayed-open or instant-open). Content exposes resolved data-side and data-align, plus Radix CSS variables --radix-tooltip-content-transform-origin, --radix-tooltip-trigger-width, --radix-tooltip-content-available-width and --radix-tooltip-content-available-height. The scoped surface wraps long text and caps width to the viewport. Content asChild requires a single noninteractive element that forwards props and ref. Do not force-mount content as a substitute for a persistent description.

Playground defaults

Reset restores preferred top placement and a 700 ms hover delay. The side and delay controls are documentation controls, not additional component props. Examples describe actions but do not perform them. Install Button separately when copying these examples; Tooltip itself has no Button dependency.