Back to Components

Minimal Tooltip

A lightweight tooltip component that displays contextual information on hover with customizable positioning and smooth fade animations.

Preview

Loading...

Installation

Install the component using the CLI.

$npx shadcn@latest add https://ankurz.me/r/tooltip.json

Usage

Import the component:

import { Tooltip } from "@/components/tooltip"

Use it in your code:

<Tooltip text="Helpful information">
  <button>Hover me</button>
</Tooltip>

Props

PropertyTypeDefaultDescription
children*ReactNode-The element that triggers the tooltip on hover.
text*string-The text content to display in the tooltip.
positionstring"top"Position of the tooltip relative to the trigger element. Options: 'top', 'bottom', 'left', 'right'.
classNamestring""Additional CSS classes to apply to the tooltip container.