Skip to content
All components
Overlays

Tooltip

Show a short text description of a control when it is hovered or receives keyboard focus, such as the name of an icon button or its keyboard shortcut.

A short label on hover or focus.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add tooltip

Then import it from @/components/ui/tooltip. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Top

Place contextual help above its trigger. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import { Button } from "@/components/ui/button"

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

export function TooltipTop() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button intent="neutral" emphasis="stroke">
              Rebuild registry
            </Button>
          </TooltipTrigger>
          <TooltipContent>Reads every file in registry/ui</TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

Bottom

Place contextual help below its trigger. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import { Button } from "@/components/ui/button"

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

export function TooltipBottom() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button intent="neutral" emphasis="ghost">
              Copy URL
            </Button>
          </TooltipTrigger>
          <TooltipContent side="bottom">/r/registry.json</TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

Icon button

Show the name of an icon-only button on hover and keyboard focus. aria-label names the button; the tooltip only describes it, so it never replaces the accessible name.

"use client"

import { SettingsIcon } from "lucide-react"

import { Button } from "@/components/ui/button"

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

export function TooltipIconButton() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button iconOnly intent="neutral" emphasis="stroke" aria-label="Workspace settings">
              <SettingsIcon />
            </Button>
          </TooltipTrigger>
          <TooltipContent>Workspace settings</TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

With shortcut

Pair a short label with the keyboard shortcut that performs the same action. Kbd displays the notation; the application still binds the shortcut.

"use client"

import { BoldIcon } from "lucide-react"

import { Button } from "@/components/ui/button"
import { Kbd } from "@/components/ui/kbd"
import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
} from "@/components/ui/tooltip"

export function TooltipWithShortcut() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button iconOnly intent="neutral" emphasis="ghost" aria-label="Bold">
              <BoldIcon />
            </Button>
          </TooltipTrigger>
          <TooltipContent className="flex items-center gap-2">
            Bold
            <Kbd>Ctrl B</Kbd>
          </TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

Right

Place contextual help to the right of its trigger. Collision handling may flip it when the viewport edge is too close.

"use client"

import { UndoIcon } from "lucide-react"

import { Button } from "@/components/ui/button"

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

export function TooltipRight() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button intent="neutral" emphasis="stroke">
              <UndoIcon />
              Undo
            </Button>
          </TooltipTrigger>
          <TooltipContent side="right">Reverts the last change only</TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

Without arrow

Hide the arrow on a tooltip. arrow={false} removes the pointer for dense layouts; the content is unchanged.

"use client"

import { CopyIcon } from "lucide-react"

import { Button } from "@/components/ui/button"

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

export function TooltipWithoutArrow() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button iconOnly intent="neutral" emphasis="ghost" aria-label="Copy link">
              <CopyIcon />
            </Button>
          </TooltipTrigger>
          <TooltipContent arrow={false}>Copy link</TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

Title and description

Show a title with supporting text. Keep tooltip text supplemental; information required to complete a task must be available elsewhere.

"use client"

import { CircleHelpIcon } from "lucide-react"

import { Button } from "@/components/ui/button"

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

export function TooltipTitleAndDescription() {
  return (
    <TooltipProvider>
      <div className="flex flex-wrap items-center gap-3">
        <Tooltip>
          <TooltipTrigger asChild>
            <Button iconOnly intent="neutral" emphasis="ghost" aria-label="About usage limits">
              <CircleHelpIcon />
            </Button>
          </TooltipTrigger>
          <TooltipContent className="flex max-w-64 flex-col gap-1 px-3 py-2">
            <span className="text-label-xs">Usage limits</span>
            <span className="text-paragraph-sm">
              Limits reset on the first day of each month. Unused requests do not roll over.
            </span>
          </TooltipContent>
        </Tooltip>
      </div>
    </TooltipProvider>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

Tooltip

Provide a short supplemental description on hover or focus.

Tooltip props
PropTypeDefaultDescription
childrenReact.ReactNode—Represents all of the things React can render.
delayDurationnumber | undefined—The duration from when the pointer enters the trigger until the tooltip gets opened. This will override the prop with the same name passed to Provider.
disableHoverableContentboolean | undefined—When true, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.
Inherited props (3)
Tooltip inherited props
PropTypeDefaultDescription
openboolean | undefined—Controlled visibility state. Pair with onOpenChange so requested state changes can be applied.
defaultOpenboolean | undefined—Initial uncontrolled visibility state. Later changes use the primitive's controls or controlled open API.
onOpenChange((open: boolean) => void) | undefined—Receive the requested open state. Apply it to open when controlled.

TooltipContent

Content region within the root composition. Keep required providers, labels and related controls from the complete example.

TooltipContent props
PropTypeDefaultDescription
forceMounttrue | undefined—Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
aria-labelstring | undefined—A more descriptive label for accessibility purpose
onEscapeKeyDown((event: KeyboardEvent) => void) | undefined—Event handler called when the escape key is down. Can be prevented.
onPointerDownOutside((event: CustomEvent<{ originalEvent: PointerEvent; }>) => void) | undefined—Event handler called when the a pointerdown event happens outside of the Tooltip. Can be prevented.
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
arrowboolean | undefinedtrueShow the pointer arrow toward the trigger. Turn it off for tooltips that sit close to their trigger or in dense layouts. Defaults to true.
Inherited props (25)
TooltipContent inherited props
PropTypeDefaultDescription
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
side"top" | "right" | "bottom" | "left" | undefined—Preferred side relative to the trigger. Collision handling can adjust the final placement where supported.
sideOffsetnumber | undefined6Spacing between the floating content and its trigger along the placement axis.
align"center" | "start" | "end" | undefined—Alignment of floating content relative to its trigger, using the supported source values.
alignOffsetnumber | undefined—Offset from the selected floating-content alignment.
arrowPaddingnumber | undefined—Minimum spacing between a floating arrow and the content's edges.
avoidCollisionsboolean | undefined—Allow floating content to adjust placement to avoid its collision boundary.
collisionBoundary(Element | null) | (Element | null)[] | undefined—Element or elements used as the boundary for floating-content collision checks.
collisionPaddingnumber | Partial<Record<"top" | "right" | "bottom" | "left", number>> | undefined—Space reserved between floating content and its collision boundary.
sticky("partial" | "always") | undefined—How floating content remains attached to its trigger while collision positioning is constrained.
hideWhenDetachedboolean | undefined—Hide floating content when its trigger becomes detached from the positioning boundary.
updatePositionStrategy("always" | "optimized") | undefined—Optimized or continuous updates to floating-content positioning, as supported by the primitive.
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

TooltipProvider

The TooltipProvider part of tooltip. Use it with the complete source composition and preserve its required parent context.

TooltipProvider props
PropTypeDefaultDescription
children(required)React.ReactNode—Represents all of the things React can render.
delayDurationnumber | undefined200The duration from when the pointer enters the trigger until the tooltip gets opened.
skipDelayDurationnumber | undefined—How much time a user has to enter another trigger without incurring a delay again.
disableHoverableContentboolean | undefined—When true, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.

TooltipTrigger

Interactive control that opens or toggles the associated content. Preserve its accessible name and the required root context.

TooltipTrigger props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (19)
TooltipTrigger inherited props
PropTypeDefaultDescription
formstring | undefined—ID of the form associated with this control, including when it is rendered outside that form element.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLButtonElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLButtonElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLButtonElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLButtonElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
disabledboolean | undefined—Make the supported control unavailable through its native or primitive disabled semantics. This does not disable arbitrary child links.
namestring | undefined—Name used by the control's form submission or primitive form integration.
type"button" | "submit" | "reset" | undefined—Native element or primitive mode defined by the source union. Choose a supported value; its meaning depends on the component.
valuestring | number | readonly string[] | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
refReact.Ref<HTMLButtonElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

Accessibility & usage

From registry/ui/tooltip.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • Reveal the visible name of an icon-only button whose accessible name already comes from aria-label.
  • Add a brief clarification or the keyboard shortcut for a control that is already labelled.
  • Explain a truncated or abbreviated label in a dense toolbar.

When not to use

  • Anything the user must read to succeed, such as form instructions, errors or warnings; keep those visible on the page.
  • Interactive content (links, buttons, inputs); a tooltip cannot be focused or operated.
  • Rich or long content such as a profile or formatted text; use a hover card or a popover.
  • Touch-first interfaces, where tooltips do not appear; the control must be understandable without it.

Anatomy

TooltipProvider
Optional shared timing (delayDuration, default 200 ms here; skipDelayDuration). A Tooltip without an explicit provider creates its own with the same default.
Tooltip
Root. Holds open state, uncontrolled or controlled with open and onOpenChange.
TooltipTrigger
The described control, normally a Button through asChild; it keeps its own accessible name.
TooltipContent
Portaled text bubble with the tooltip role and an optional arrow (arrow, default true). Positioned by side and align, offset by sideOffset (default 6). May hold a short title and supporting text.

Keyboard & interaction

  • Opens after the provider delay when a mouse pointer rests on the trigger, and when the trigger receives keyboard focus.
  • While open, the content describes the trigger through aria-describedby, so screen readers announce it after the control's name.
  • Escape closes it without moving focus (WCAG 1.4.13 dismissible); pressing the trigger, blurring it or moving the pointer away also closes it.
  • The pointer can move from the trigger onto the tooltip without it closing, so magnified users can read it (WCAG 1.4.13 hoverable and persistent).
  • Within one provider, moving between neighboring triggers opens the next tooltip without waiting for the delay again.

Responsive behavior

  • Touch input does not open tooltips; on phones and tablets the control must make sense from its icon, label and context alone.
  • Keep content to a single short line; long text wraps but must still fit a 320px viewport (WCAG 1.4.10).
  • Collision handling flips the tooltip to the opposite side near viewport edges; never rely on one side for meaning.
  • Keep icon-only triggers at least 24x24 CSS pixels (WCAG 2.5.8) and the tooltip from covering the next control a user is likely to hover or focus (WCAG 2.4.11).

Content guidelines

  • One short phrase in sentence case without a trailing period: 'Workspace settings', 'Copy link'.
  • For icon buttons, use the same words as the aria-label so what users see and hear matches.
  • Show keyboard shortcuts with Kbd after the label ('Bold Ctrl B'); the shortcut must also be bound by the application.
  • Add information, not decoration: describe what happens ('Reverts the last change only') rather than restating the label.

Alternatives

  • Hover card — A richer, read-only preview of a link's destination.
  • Popover — Interactive or longer content the user opens on purpose.
  • Field — Persistent hint and error text for form controls.

Resources