Tooltip
A tooltip names an icon-only control when it is hovered or focused.
When to use
Section titled “When to use”- 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.
Do and don’t
Section titled “Do and don’t”Anatomy
Section titled “Anatomy”- 1Tooltip on foreground
- 2Icon-only trigger
A small label in inverse colors (foreground fill, background text) on radius-md, with an arrow toward the control.
Variants
Section titled “Variants”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> )}<script setup lang="ts">import { Download } from "@lucide/vue"import { Button } from "@/components/ui/button"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"</script>
<template> <TooltipProvider :delay-duration="0"> <Tooltip> <TooltipTrigger as-child> <Button variant="outline" size="icon" aria-label="Unduh laporan"><Download /></Button> </TooltipTrigger> <TooltipContent>Unduh laporan</TooltipContent> </Tooltip> </TooltipProvider></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class TooltipDemo extends StatelessWidget { const TooltipDemo({super.key});
@override Widget build(BuildContext context) { return ShadTooltip( builder: (context) => const Text('Unduh laporan'), child: ShadIconButton.outline(icon: const Icon(LucideIcons.download), onPressed: () {}), ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/tooltip.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/tooltip.jsonAccessibility
Section titled “Accessibility”- 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.
