Skip to content

Tooltip

Download .md

A tooltip names an icon-only control when it is hovered or focused.

  • Use it to label icon buttons, such as download or edit.
  • Keep it to a few words; put longer help in the page.
  • Don’t put anything people need to click in a tooltip.
React
Vue
DoUse a tooltip to name an icon-only button in a word or two.
Don'tDon't hide instructions or policy in a tooltip.
12
  1. 1Tooltip on foreground
  2. 2Icon-only trigger

A small label in inverse colors (foreground fill, background text) on radius-md, with an arrow toward the control.

There is one style. It can appear on any side of the control.

React Vue Flutter Type Default Use
TooltipProvider delay TooltipProvider :delay-duration none number (ms) provider default How long before it shows.
TooltipContent side TooltipContent side anchor top | right | bottom | left top Where it appears.
TooltipTrigger render TooltipTrigger as-child child element button The control it names.
import { DownloadIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
export default function TooltipDemo() {
return (
<TooltipProvider delay={0}>
<Tooltip>
<TooltipTrigger render={<Button variant="outline" size="icon" aria-label="Unduh laporan" />}>
<DownloadIcon />
</TooltipTrigger>
<TooltipContent>Unduh laporan</TooltipContent>
</Tooltip>
</TooltipProvider>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/tooltip.json
  • Shows on keyboard focus as well as hover.
  • The control still needs an aria-label; the tooltip helps sighted people, the label helps screen readers.