Tooltip

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

shadcn/ui docs

Installation

pnpm dlx shadcn@latest add https://neobrutalism.dev/r/tooltip.json

Usage

import { Button } from '@/components/ui/button'
import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
} from '@/components/ui/tooltip'
<TooltipProvider>
  <Tooltip>
    <TooltipTrigger render={<Button variant="noShadow" />}>Hover</TooltipTrigger>
    <TooltipContent>
      <p>Add to library</p>
    </TooltipContent>
  </Tooltip>
</TooltipProvider>

Examples

Default

Side

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

With Keyboard Shortcut

Render a Kbd inside TooltipContent to show the keyboard shortcut for an action.

Disabled Button

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