ProComponents, templates & AI tooling
HeroUI
27.7k

TooltipUpdated

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

Usage

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

Anatomy

import { Tooltip, Button } 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>
)

Examples

Placement

With Arrow

Custom Triggers

Render Function

Customization

Tailwind CSS

Global CSS

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;
  }
}

Styling Reference

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

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
shouldSkipAnimationbooleanfalseWhether to skip the enter and exit animations when moving quickly from one tooltip to another

Tooltip.Content

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
renderDOMRenderFunction<keyof React.JSX.IntrinsicElements, TooltipRenderProps>-Overrides the default DOM element with a custom render function.

Tooltip.Trigger

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

Tooltip.Arrow

PropTypeDefaultDescription
childrenReact.ReactNode-Custom arrow element
classNamestring-Additional CSS classes
renderDOMRenderFunction<keyof React.JSX.IntrinsicElements, OverlayArrowRenderProps>-Overrides the default DOM element with a custom render function.

On this page