Skip to content
Browse docs and components

Tooltip

tooltip

A short description of a control, shown on hover and on keyboard focus, with an optional arrow. Built on the Base UI primitive and portalled so a tooltip is never clipped by the toolbar or table it belongs to.

Responsive

Install

$npxshadcnadd@forme/tooltip

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

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

<TooltipProvider>
  <Tooltip>
    <TooltipTrigger asChild>
      <Button iconOnly leadingIcon={Copy} aria-label="Copy" />
    </TooltipTrigger>
    <TooltipContent>Copy</TooltipContent>
  </Tooltip>
</TooltipProvider>

When to use

Reach for it

  • Naming an icon-only control, or adding a short hint to something already labelled.

Use something else

  • Anything essential. A tooltip cannot be reached by touch, so the information must exist elsewhere.
  • Interactive content like links or buttons — that is a Popover.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

TooltipTrigger

PropTypeDefaultDescription
asChildboolean—Render as the single child element instead of a <button>, keeping the trigger behaviour.

Also takes every prop of Base UI Tooltip.Trigger.

TooltipContent

PropTypeDefaultDescription
arrowbooleantrueThe caret pointing at the trigger. On by default; the popup grows out of it.

Also takes every prop of Base UI Tooltip.Popup and Pick<ComponentProps<typeof TooltipPrimitive.Positioner>, "side" | "sideOffset" | "align">.

The other parts

  • TooltipProviderTakes Base UI Tooltip.Provider
  • TooltipTakes Base UI Tooltip.Root
  • TooltipArrowTakes Base UI Tooltip.Arrow

Accessibility

  • It opens on keyboard focus as well as hover.
  • It describes its trigger; an icon-only trigger still needs its own aria-label.

Motion

  • It opens after 200ms. Once one has shown, its neighbours open instantly while the pointer travels between them.