Summit
ComponentsOverlays

Tooltip

A Tooltip shows users the name of a control while the pointer or keyboard focus is on it.

When to Use

  • to show the name of an icon-only Button, in the words of its aria-label
  • to show the shortcut of a control, in a Kbd after its name
  • to name the items of a Sidebar that is collapsed to icons, through the tooltip prop of SidebarMenuButton

When Not to Use

  • for text that users need to finish a task, such as a hint or a format (write it on the page, for example in the FieldDescription of a Field)
  • for the text behind an info icon (use a Popover with openOnHover)
  • for content that contains a link or a Button, as focus never moves into a Tooltip (use a Popover)
  • to preview the page behind a link (use a Hover Card)

See Popover for a comparison of the Popover, the Tooltip, and the Hover Card.

Avoid placing text that users need to finish a task in a Tooltip, as a tap doesn’t open a Tooltip and screen readers don’t announce one.

DoWrite a hint that users need on the page, for example in a FieldDescription.
Don’tWhen the hint is in a Tooltip, users on a touch screen can’t open it and screen readers don’t announce it, so those users never learn the format.

Anatomy

ElementUsage
PopupRequired
KbdOptional
TriggerRequired

TooltipContent renders the portal, the positioner, the popup, and the arrow that points at the trigger.

Behavior

A Tooltip responds to a pointer and to keyboard focus. A tap doesn’t open one.

By default, a Tooltip inside a TooltipProvider appears after the pointer has rested on its trigger for 200ms. If another Tooltip is opened within 400ms of one closing, it appears with no delay and no transition. This allows users to move the pointer along a toolbar and read each name in turn. If there is no TooltipProvider, every Tooltip waits 600ms, which is Base UI’s default. When the trigger receives keyboard focus, its Tooltip opens immediately.

A Tooltip closes when the pointer or focus moves away, when users press Escape, and when users click its trigger.

Position and Size

By default, a Tooltip opens above its trigger, centered on it. If it doesn’t fit there, Base UI moves it to another side. To change the position, set side, sideOffset, align, and alignOffset on TooltipContent.

The popup is as wide as its text, up to 320px, and longer text wraps.

Content

StringRuleExampleCounterexample
NameUse the words of the trigger’s aria-label“Add client”“Click to add a new client”
NameSentence case“Add client”“Add Client”
ShortcutPlace it in a Kbd after the name“Print the invoice ⌘P”“Print the invoice (⌘P)”

Accessibility

A Tooltip is visual only. Base UI sets no role on the popup, and no attribute connects the popup to the trigger, so screen readers announce the trigger’s own name and never the Tooltip.

Requirements

The trigger of a Tooltip needs its own name so that screen readers can announce it, as WCAG 2.2 SC 4.1.2 Name, Role, Value requires. The Tooltip itself isn’t announced. On an icon-only Button, set aria-label to the words in the Tooltip.

Installation

npx shadcn@latest add @summit/tooltip

Usage

Render one TooltipProvider around the app so that all Tooltips share the 200ms delay.

import { Button } from '@/components/ui/button';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import { PlusIcon } from '@phosphor-icons/react';

<TooltipProvider>
    <Tooltip>
        <TooltipTrigger render={<Button variant="outline" size="icon" aria-label="Add client" />}>
            <PlusIcon />
        </TooltipTrigger>
        <TooltipContent>Add client</TooltipContent>
    </Tooltip>
</TooltipProvider>;

With a Shortcut

To show a shortcut, place a Kbd or a KbdGroup after the text.

With a Shortcut
import { Kbd, KbdGroup } from '@/components/ui/kbd';

<Tooltip>
    <TooltipTrigger render={<Button variant="outline" />}>Print</TooltipTrigger>
    <TooltipContent>
        Print the invoice
        <KbdGroup>
            <Kbd>⌘</Kbd>
            <Kbd>P</Kbd>
        </KbdGroup>
    </TooltipContent>
</Tooltip>;

API Reference

The parts accept the props of their matching parts in Base UI’s Tooltip, where TooltipContent is Tooltip.Popup. See the Base UI Tooltip documentation for closeDelay, timeout, disabled, and closeOnClick.

TooltipProvider

PropTypeDefaultDescription
delaynumber200The delay before the first Tooltip opens, in milliseconds

TooltipContent

PropTypeDefaultDescription
side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end''top'The side of the trigger the Tooltip opens on
sideOffsetnumber | OffsetFunction4The gap between the trigger and the Tooltip, in pixels
align'start' | 'center' | 'end''center'The edge of the trigger the Tooltip lines up with
alignOffsetnumber | OffsetFunction0A shift along that edge, in pixels

On this page