Tooltip

Displays informative text when users hover over or focus on an element

Import

import { Tooltip } from '@heroui/react';

Usage

"use client";

import {Button, Tooltip} from "@heroui/react";
import {Icon} from "@iconify/react";

export function TooltipBasic() {
  return (
    <div className="flex items-center gap-4">
      <Tooltip delay={0}>
        <Button variant="secondary">Hover me</Button>
        <Tooltip.Content>
          <p>This is a tooltip</p>
        </Tooltip.Content>
      </Tooltip>

      <Tooltip delay={0}>
        <Button isIconOnly variant="tertiary">
          <Icon icon="gravity-ui:circle-info" />
        </Button>
        <Tooltip.Content>
          <p>More information</p>
        </Tooltip.Content>
      </Tooltip>
    </div>
  );
}

Anatomy

Import all parts and piece them together.

import { Tooltip } from '@heroui/react';

export default () => (
  <Tooltip>
    <Tooltip.Trigger>
      <button>Hover for tooltip</button>
    </Tooltip.Trigger>
    <Tooltip.Content>
      <Tooltip.Arrow />
      Helpful information about this element
    </Tooltip.Content>
  </Tooltip>
)

With Arrow

"use client";

import {Button, Tooltip} from "@heroui/react";

export function TooltipWithArrow() {
  return (
    <div className="flex items-center gap-4">
      <Tooltip delay={0}>
        <Button variant="secondary">With Arrow</Button>
        <Tooltip.Content showArrow>
          <Tooltip.Arrow />
          <p>Tooltip with arrow indicator</p>
        </Tooltip.Content>
      </Tooltip>

      <Tooltip delay={0}>
        <Button variant="primary">Custom Offset</Button>
        <Tooltip.Content showArrow offset={12}>
          <Tooltip.Arrow />
          <p>Custom offset from trigger</p>
        </Tooltip.Content>
      </Tooltip>
    </div>
  );
}

Placement

Hover buttons
"use client";

import {Button, Tooltip} from "@heroui/react";

export function TooltipPlacement() {
  return (
    <div className="grid grid-cols-3 gap-4">
      <div />
      <Tooltip delay={0}>
        <Button className="w-full" variant="tertiary">
          Top
        </Button>
        <Tooltip.Content showArrow placement="top">
          <Tooltip.Arrow />
          <p>Top placement</p>
        </Tooltip.Content>
      </Tooltip>
      <div />

      <Tooltip delay={0}>
        <Button className="w-full" variant="tertiary">
          Left
        </Button>
        <Tooltip.Content showArrow placement="left">
          <Tooltip.Arrow />
          <p>Left placement</p>
        </Tooltip.Content>
      </Tooltip>

      <div className="flex items-center justify-center">
        <span className="text-muted text-sm">Hover buttons</span>
      </div>

      <Tooltip delay={0}>
        <Button className="w-full" variant="tertiary">
          Right
        </Button>
        <Tooltip.Content showArrow placement="right">
          <Tooltip.Arrow />
          <p>Right placement</p>
        </Tooltip.Content>
      </Tooltip>

      <div />
      <Tooltip delay={0}>
        <Button className="w-full" variant="tertiary">
          Bottom
        </Button>
        <Tooltip.Content showArrow placement="bottom">
          <Tooltip.Arrow />
          <p>Bottom placement</p>
        </Tooltip.Content>
      </Tooltip>
      <div />
    </div>
  );
}

Custom Triggers

John DoeJD
Active
"use client";

import {Avatar, Chip, Tooltip} from "@heroui/react";
import {Icon} from "@iconify/react";

export function TooltipCustomTrigger() {
  return (
    <div className="flex items-center gap-6">
      <Tooltip delay={0}>
        <Tooltip.Trigger aria-label="User avatar">
          <Avatar>
            <Avatar.Image
              alt="John Doe"
              src="https://img.heroui.chat/image/avatar?w=400&h=400&u=1"
            />
            <Avatar.Fallback>JD</Avatar.Fallback>
          </Avatar>
        </Tooltip.Trigger>
        <Tooltip.Content showArrow>
          <Tooltip.Arrow />
          <div className="flex flex-col gap-0 py-1">
            <p className="font-semibold">Jane Doe</p>
            <p className="text-muted text-xs">jane@example.com</p>
          </div>
        </Tooltip.Content>
      </Tooltip>

      <Tooltip delay={0}>
        <Tooltip.Trigger aria-label="Status chip">
          <Chip color="success">
            <Icon icon="gravity-ui:circle-check-fill" width={12} />
            Active
          </Chip>
        </Tooltip.Trigger>
        <Tooltip.Content className="flex items-center gap-1.5">
          <span className="relative flex size-2">
            <span className="bg-success absolute inline-flex h-full w-full animate-ping rounded-full opacity-75" />
            <span className="bg-success relative inline-flex size-2 rounded-full" />
          </span>
          <p>Jane is currently online</p>
        </Tooltip.Content>
      </Tooltip>

      <Tooltip delay={0}>
        <Tooltip.Trigger aria-label="Info icon">
          <div className="bg-accent-soft rounded-full p-2">
            <Icon className="text-accent" icon="gravity-ui:circle-question" />
          </div>
        </Tooltip.Trigger>
        <Tooltip.Content showArrow>
          <Tooltip.Arrow />
          <div className="max-w-xs px-1 py-1.5">
            <p className="mb-1 font-semibold">Help Information</p>
            <p className="text-muted text-sm">
              This is a helpful tooltip with more detailed information about this feature.
            </p>
          </div>
        </Tooltip.Content>
      </Tooltip>
    </div>
  );
}

Styling

Passing Tailwind CSS classes

import {Tooltip, Button} from '@heroui/react';

function CustomTooltip() {
  return (
    <Tooltip>
      <Button>Hover me</Button>
      <Tooltip.Content className="bg-accent text-accent-foreground">
        <p>Custom styled tooltip</p>
      </Tooltip.Content>
    </Tooltip>
  );
}

Customizing the component classes

To customize the Tooltip component classes, you can use the @layer components directive.
Learn more.

@layer components {
  .tooltip {
    @apply rounded-xl shadow-lg;
  }

  .tooltip__trigger {
    @apply cursor-help;
  }
}

HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.

CSS Classes

The Tooltip component uses these CSS classes (View source styles):

Base Classes

  • .tooltip - Base tooltip styles with animations
  • .tooltip__trigger - Trigger element styles

Interactive States

The component supports animation states:

  • Entering: [data-entering] - Applied during tooltip appearance
  • Exiting: [data-exiting] - Applied during tooltip disappearance
  • Placement: [data-placement="*"] - Applied based on tooltip position

API Reference

Tooltip Props

PropTypeDefaultDescription
childrenReact.ReactNode-Trigger element and content
delaynumber700Delay in milliseconds before showing tooltip
closeDelaynumber0Delay in milliseconds before hiding tooltip
trigger"hover" | "focus""hover"How the tooltip is triggered
isDisabledbooleanfalseWhether the tooltip is disabled

Tooltip.Content Props

PropTypeDefaultDescription
childrenReact.ReactNode-Content to display in the tooltip
showArrowbooleanfalseWhether to show the arrow indicator
offsetnumber3 (7 with arrow)Distance from the trigger element
placement"top" | "bottom" | "left" | "right" (and variants)"top"Placement of the tooltip
classNamestring-Additional CSS classes

Tooltip.Trigger Props

PropTypeDefaultDescription
childrenReact.ReactNode-Element that triggers the tooltip
classNamestring-Additional CSS classes

Tooltip.Arrow Props

PropTypeDefaultDescription
childrenReact.ReactNode-Custom arrow element
classNamestring-Additional CSS classes