Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Tooltip for React

Display information on hover or focus.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/base/tooltip.json

Anatomy

TooltipTrigger
TooltipArrow
└── TooltipArrowTip
TooltipContent
└── TooltipPositioner

Usage

import { Button } from "@/components/ui/button";
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/components/ui/tooltip";
<Tooltip>
  <TooltipTrigger asChild>
    <Button variant="outline">Hover</Button>
  </TooltipTrigger>
  <TooltipContent>
    <p>Add to library</p>
  </TooltipContent>
</Tooltip>

Accessibility

KeyDescription
Enter
Activate the focused item.
Space
Activate the focused control.

Demos

Sides

Position the tooltip with Ark positioning.placement.

Keyboard

Tooltip with a keyboard shortcut.

Disabled

Show a tooltip on a disabled button by wrapping it with a span.

Rtl

Right-to-left tooltip. See the RTL configuration guide for document direction.

API Reference

Tooltip

PropType
AttributeType

TooltipTrigger

button

PropType
AttributeType

TooltipArrow

div

PropType
AttributeType

TooltipPositioner

div

PropType
AttributeType
CSS variableType
--transform-originstring

TooltipContent

div

PropType
AttributeType
CSS variableType
--transform-originstring

TooltipProvider

PropType
children?React.ReactNode
AttributeType