PeakUI

Tooltip

Informative text on hover or focus

Usage

import {Tooltip} from "@peakui/react";

Anatomy

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

export default () => (
  <Tooltip>
    <Button>Hover for tooltip</Button>
    <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

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

  .tooltip__trigger {
    @apply cursor-help;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

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

Slots

  • [data-slot="tooltip"] - The tooltip content element
  • [data-slot="tooltip-trigger"] - The Tooltip.Trigger element
  • [data-slot="tooltip-arrow"] - The arrow wrapper
  • [data-slot="overlay-arrow"] - The default arrow SVG

Interactive States

The tooltip content carries RAC animation and positioning states:

  • Entering: [data-entering="true"]
  • Exiting: [data-exiting="true"]
  • Placement: [data-placement="top | bottom | left | right"]

The trigger supports both pseudo-classes and data attributes:

  • Focus: :focus-visible or [data-focus-visible="true"]

API Reference

Tooltip

PropTypeDefaultDescription
childrenReact.ReactNode-The trigger element followed by Tooltip.Content
delaynumber1500Delay in milliseconds before the tooltip shows; read from the --tooltip-delay theme variable when omitted
closeDelaynumber500Delay in milliseconds before the tooltip hides; read from the --tooltip-close-delay theme variable when omitted
trigger'hover' | 'focus''hover''hover' opens for both hover and focus, 'focus' for focus only
shouldCloseOnPressbooleantrueWhether the tooltip closes when the trigger is pressed
isDisabledbooleanfalseWhether the tooltip is disabled
isOpenboolean-Controlled open state
defaultOpenbooleanfalseInitially open, without controlling
onOpenChange(isOpen: boolean) => void-Called when the tooltip opens or closes
shouldSkipAnimationbooleanfalseLet React Aria skip the enter and exit animations when moving quickly from one tooltip to another

Tooltip.Content

PropTypeDefaultDescription
childrenReact.ReactNode-Content of the tooltip
placementPlacement'top'Placement relative to the trigger: 'top', 'bottom', 'left', 'right' with start/end/top/bottom variants
offsetnumber3, or 7 with showArrowDistance from the trigger element
crossOffsetnumber0Cross-axis offset from the trigger
showArrowbooleanfalseWhether the arrow indicator is expected; reserves the larger default offset
shouldFlipbooleantrueWhether the tooltip flips when it does not fit
containerPaddingnumber12Distance the tooltip keeps from the viewport edge
arrowBoundaryOffsetnumber0Boundary offset for the arrow positioning
classNamestring | ((renderProps) => string)-Additional classes, or a function of the tooltip state
renderDOMRenderFunction<'div', TooltipRenderProps>-Replaces the rendered <div> with your own element

Tooltip.Trigger

PropTypeDefaultDescription
childrenReact.ReactNode-Non-interactive element to make focusable and hoverable
classNamestring-Additional classes
renderDOMRenderFunction<E, undefined>-Replaces the rendered <div> with your own element; E defaults to 'div'

Tooltip.Arrow

PropTypeDefaultDescription
childrenReact.ReactNode-Custom arrow element; defaults to a 12x12 SVG
classNamestring-Additional classes
renderDOMRenderFunction<'div', OverlayArrowRenderProps>-Replaces the rendered wrapper <div> with your own element; the arrow SVG stays as its child

Render Props

PropTypeDescription
Tooltip.Content className(renderProps: TooltipRenderProps) => stringComputes classes from placement, isEntering, isExiting and state

On this page