Skip to content

Now in the official shadcn registry directory.

Start free

Tooltip

A tooltip with portal, arrow and directional slide/zoom animations - Tooltip wraps its own Provider, so a single import works out of the box.

overlay
A free styled version is available

Installation

Run the following command

npx shadcn@latest add @ai2/tooltip

Dependencies, the @ai2/tokens theme and the component file are installed together.

Usage

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

<Tooltip>
  <TooltipTrigger asChild>
    <Button variant="outline">Hover me</Button>
  </TooltipTrigger>
  <TooltipContent>Deploys in ~62ms</TooltipContent>
</Tooltip>

Wrap the trigger with TooltipTrigger asChild to attach the tooltip to any element. The content renders in a portal and carries an arrow automatically.

Examples

Sides

Sizes

Shared provider

Wrap groups of tooltips in an explicit TooltipProvider to share timing - with delayDuration={0} adjacent tooltips open instantly as the pointer moves between triggers.

Props

Every part also forwards its underlying radix props - e.g. open / onOpenChange on Tooltip and side on TooltipContent.

PropTypeDefaultDescription
size"sm" | "md""md"Padding preset on TooltipContent: sm is px-2 py-0.5, md is px-2.5 py-1.
sideOffsetnumber6Gap in pixels between the trigger and the tooltip (on TooltipContent).
delayDurationnumber200Hover delay in milliseconds before the tooltip opens (on TooltipProvider).

ai2 Tooltip: hover and focus hints for React, zero setup

The ai2 Tooltip is a shadcn-compatible tooltip component for React, built on the radix-ui Tooltip primitive and styled with Tailwind CSS v4. It shows a short hint next to a control on hover or keyboard focus, rendered in a portal with an arrow and directional slide and zoom animations. Each Tooltip wraps its own provider with a 200ms delay, so a single import works with no app-level setup.

Because it ships through the shadcn registry format, you install it with one CLI command, an MCP agent, or a copy-paste, and the source lands in your own project. You own the file; there is no runtime dependency on ai2 itself. The live example above is the exact component you get.

What is the ai2 Tooltip?

It is a four-part composition: TooltipProvider, Tooltip, TooltipTrigger and TooltipContent. The anatomy matches shadcn/ui exactly, so existing snippets, muscle memory and AI agents keep working without changes. In everyday use you only import three parts; the provider is built into the root.

The content renders through a radix portal above everything else, adds a small rotated-square arrow automatically, and animates in from the side it is placed on. Styling uses the primary token pair for a high-contrast bubble, so the tooltip stays readable in both light and dark mode from day one, and a size prop trims the padding for dense toolbars (sm) or keeps the comfortable default inset (md).

Why use it

  • Accessible by construction: The radix-ui Tooltip primitive opens on keyboard focus as well as hover, associates the content with the trigger for screen readers, and closes on Escape.
  • Zero-setup provider: Tooltip wraps its own TooltipProvider with a 200ms delayDuration, so a single component works anywhere without wrapping your app first.
  • Portal plus arrow, handled: Content renders in a portal at z-50 with a built-in arrow, so tooltips are never clipped by overflow containers and always point at their trigger.
  • Directional animations: data-side drives a fade, zoom and 1-notch slide from the correct direction, powered by tw-animate-css utilities rather than a JS animation library.
  • Agent-readable metadata: The registry item describes its parts and intended use in plain words, so an MCP agent can find, inspect and install it without guessing.

Features

  • shadcn registry install: One command adds the component, its dependencies and the @ai2/tokens theme to your project.
  • asChild trigger: TooltipTrigger forwards the radix asChild prop, so the tooltip attaches to your own Button, icon or link without an extra wrapper element.
  • Four placement sides: TooltipContent accepts side="top" | "right" | "bottom" | "left" plus alignment and collision props from radix, with a 6px default sideOffset.
  • Shared delay via provider: Wrap a toolbar in an explicit TooltipProvider to share timing; with delayDuration={0} adjacent tooltips open instantly as the pointer moves along.
  • Controlled open state: The root forwards open, onOpenChange and defaultOpen, so you can drive a tooltip from React state when needed.
  • Data attributes for styling: Every part exposes data-slot, and the content exposes data-state and data-side, so you can restyle placements from CSS without forking the component.

Production tips

  • Keep tooltip text short: A tooltip is a label, not a paragraph. Aim for a few words like "View build logs"; if you need sentences or interactive content, use a Popover instead.
  • Never hide essential info in tooltips: Tooltips do not open on tap-and-hold on many touch devices, so anything required to complete a task must also be visible in the UI itself.
  • Use asChild on real controls: Attach the trigger to a focusable element like a Button so keyboard users can reach the tooltip. A tooltip on a plain div is invisible to them.
  • Share a provider per toolbar: For rows of icon buttons, wrap the group in TooltipProvider with a low delayDuration so hints follow the pointer without a per-button wait.
  • Do not duplicate visible labels: If the button already says Redeploy, a tooltip saying Redeploy is noise. Reserve tooltips for icon-only controls and genuine extra context.

Works with the rest of ai2

Tooltips explain compact controls across the registry. Attach one to an icon-only ai2 Button or ai2 Toggle via asChild, and show keyboard shortcuts inside the bubble with ai2 Kbd.

Pair it with an ai2 Avatar to reveal a user's full name on hover, and reach for the ai2 Popover when the content needs to be interactive or stay open. Everything shares one token source, so combinations stay visually consistent in both modes.

FAQs

Get new components in your inbox

Component drops, new themes and release notes. No spam, and you can unsubscribe from any email.

© 2026 ai2 design system · MIT licensed · Built with its own components