Skip to content

Design system

Documentation

DesignComponents / Tooltip

Components / Tooltip

Beta

Tooltip

Use Tooltip for brief supplemental context attached to an existing control. Essential instructions must remain visible.

On this page

Examples

Hover and focus

The same supplemental message is available from pointer hover and keyboard focus.

Tooltip available on hover and focus

Size and multiline

Use sm for a short hint, md (the default) when the message needs two short lines, and lg when it needs a little more room.

Tooltip small, medium, and large sizes

IconButton context

Tooltips clarify an unfamiliar icon while the control keeps its own accessible name.

IconButton with supplemental Tooltip

Supported positions

Use side and align props when the trigger needs a different placement.

Tooltip placement comparison

Provider timing

Coordinate a related group of tooltips with shared delay and close timing.

Two Tooltips using one Provider

Arrow and shortcut

An optional arrow and a keyboard shortcut can reinforce a short, supplemental message.

Tooltip with arrow and keyboard shortcut

Controlled visibility

Feature state can control visibility when the surrounding interaction needs coordination.

Controlled Tooltip preview

Short, bounded content

Keep supplemental text concise and within the popup max width.

Tooltip with bounded content

When to use

Use Tooltip for a short clarification, a keyboard shortcut, or context for an icon-only control. Use visible helper text when the information affects task completion, and use Dialog or Popover for interactive content.

Usage

tooltip-hover-focus.tsx
"use client";

import { HelpCircle } from "@phuctech/ui/icons";
import { IconButton } from "@phuctech/ui/components/icon-button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@phuctech/ui/components/tooltip";

export function Example() {
  return (
    <TooltipProvider>
      <Tooltip>
        <TooltipTrigger render={<IconButton aria-label="What is a workspace?" variant="outline"><HelpCircle aria-hidden="true" /></IconButton>} />
        <TooltipContent> A workspace keeps a team&apos;s settings together.</TooltipContent>
      </Tooltip>
    </TooltipProvider>
  );
}

Wrap related tooltips in TooltipProvider. Compose the trigger with Button or IconButton through Base UI's render prop to avoid nested buttons. Use TooltipArrow only when the visual connection helps; it is decorative.

Behavior

  • Pointer hover opens after the provider/trigger delay; keyboard focus opens immediately enough to be discoverable.
  • Escape and leaving the trigger close the tooltip; the trigger remains the focus owner.
  • Tooltip content is portaled and positioned against the trigger so nearby overflow does not clip it.

API

Component API
PropTypeDefaultDescriptionConstraints
TooltipProviderBase UI provider propsCoordinates delay and pointer transitions for a group of tooltips.Place it around related triggers.
TooltipRoot propsControls one tooltip relationship.Use disabled when the context should not appear.
TooltipTriggerTrigger propsAttaches the tooltip to a focusable element.Keep the trigger accessible without the tooltip.
TooltipContentPopup props + side/align/sideOffset + sizeside=top, sideOffset=8, size="md"Portaled supplemental text; size sm/md/lg sets max width and padding.Keep it short and non-essential.
TooltipArrowarrow propsOptional decorative connection to the trigger.Do not rely on the arrow for meaning.

Tokens

Component tokens
TokenRoleEffective valueUsage
--color-text-primary / --color-bg-pageTooltip contrastforeground on backgroundUses a high-contrast text surface for brief context.
--radius-mdPopup geometryshared medium radiusKeeps supplemental surfaces compact.
--motion-duration-fastOpen/close timing120msTooltip motion is quick and respects reduced motion.

Accessibility

  • The trigger must have its own accessible name; tooltip text is supplementary.
  • Verify the tooltip opens from keyboard focus, not only a mouse hover.
  • Never put a required instruction, error, or interactive form only inside a tooltip.

Do and don’t

Do

Explain an unfamiliar icon in one short sentence and keep the trigger usable without it.

Don’t

Use a tooltip for a paragraph, a required form label, or an action that needs a click.

  • IconButton is a common tooltip trigger for icon-only actions.
  • Dialog handles longer tasks and focus-managed content.