105k
New

Tooltip

A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.

import { Button } from "@/components/ui/button"
import {
  Tooltip,

Installation

Run the following command:

pnpm dlx shadcn@latest add tooltip

Add the TooltipProvider to the root of your app.

app/layout.tsx
import { TooltipProvider } from "@/components/ui/tooltip"
 
export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <TooltipProvider>{children}</TooltipProvider>
      </body>
    </html>
  )
}

Usage

import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/components/ui/tooltip"
<Tooltip>
  <TooltipTrigger>Hover</TooltipTrigger>
  <TooltipContent>
    <p>Add to library</p>
  </TooltipContent>
</Tooltip>

Examples

Side

Use the side prop to change the position of the tooltip.

import { Button } from "@/components/ui/button"
import {
  Tooltip,

With Keyboard Shortcut

import { Button } from "@/components/ui/button"
import { Kbd } from "@/components/ui/kbd"
import {

Disabled Button

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

import { Button } from "@/components/ui/button"
import {
  Tooltip,

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

"use client"

import { Button } from "@/examples/radix/ui-rtl/button"

API Reference

See the Radix Tooltip documentation.