Tooltip

A short hover or focus label for an already-named control.

Source
$npx @dinachi/cli@latest add tooltip
side
align
sideOffset
variant
showArrow

Usage

import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
import { Button } from "@/components/ui/button"
import { Plus } from "lucide-react"

export function AddButton() {
  return (
    <TooltipProvider>
      <Tooltip>
        <TooltipTrigger render={<Button variant="outline" size="icon" aria-label="Add item" />}>
          <Plus className="h-4 w-4" />
        </TooltipTrigger>
        <TooltipContent>Add item</TooltipContent>
      </Tooltip>
    </TooltipProvider>
  )
}

Examples

A tooltip on an icon button.
import {
  TooltipProvider,
  Tooltip,
  TooltipTrigger,
  TooltipContent,
} from '@/components/ui/tooltip';
import { Plus } from 'lucide-react';

export function Example() {
  return (
    <TooltipProvider>
      <Tooltip>
        <TooltipTrigger>
          <Plus className="h-4 w-4" />
        </TooltipTrigger>
        <TooltipContent>
          Add new item
        </TooltipContent>
      </Tooltip>
    </TooltipProvider>
  );
}

Notes

Custom content

TooltipContent passes side, align and sideOffset to the positioner and the rest to the popup. For other positioner options, such as collision handling, compose TooltipPortal, TooltipPositioner, TooltipPopup and TooltipArrow.

Supplementary content only

It shows only on hover or focus. Put nothing in it needed to finish the task, and nothing interactive.

API

openboolean
Controlled open state.
defaultOpenboolean = false
Starts open when uncontrolled.
onOpenChange(open, details) => void
Runs when the tooltip opens or closes.
disabledboolean = false
Stops the tooltip from opening.
disableHoverablePopupboolean = false
Closes when the pointer leaves the trigger, even onto the popup.
trackCursorAxis"none" | "x" | "y" | "both" = "none"
Follows the cursor along an axis.

Accessibility

  • No aria-describedby link, so screen readers skip the popup. Name the trigger.
  • An icon-only trigger needs an aria-label; it can repeat the tooltip text.
  • Opening on keyboard focus skips the animation.
  • Reduced motion drops the scale; only the fade remains.