overlay

Tooltip

A short text hint shown on hover and keyboard focus. Includes its own provider.

npx blankui add tooltip

When to use

  • Naming an icon-only button for sighted users.
  • A short hint of a few words.

Use something else when

No TooltipProvider is needed. The trigger must be focusable, so use asChild with a Button.

Import

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

Example

import { Copy } from "lucide-react"

;<Tooltip>
  <TooltipTrigger asChild>
    <Button size="icon" variant="ghost" aria-label="Copy">
      <Copy />
    </Button>
  </TooltipTrigger>
  <TooltipContent>Copy to clipboard</TooltipContent>
</Tooltip>

Mistakes to avoid

AvoidInstead
<TooltipProvider> around the appNothing. Each Tooltip has its own provider.
title="..." attributes for hints<Tooltip>
A Tooltip as the only label of an icon buttonGive the Button an aria-label as well

Install with the shadcn CLI: npx shadcn add https://blank.vageshwar.dev/r/tooltip.json