Equality
Equality

Tooltip

Hover hint showing contextual text

View Markdown

Overview

Tooltip shows a small hint anchored to an element when the user hovers or focuses it. It’s built on Radix UI Tooltip, so it opens on hover and keyboard focus, dismisses on blur or Esc, and includes a pointer arrow.

Keep tooltips short and only use them to add non-essential (but helpful) hints or expanded content. For rich or interactive overlays use a Popover. The content renders in a portal, so it escapes overflow clipping.

Usage

Import the parts:

import {
  Tooltip,
  TooltipTrigger,
  TooltipContent,
  TooltipProvider,
} from "@eqtylab/equality";

Wrap the app (or a section) in a single TooltipProvider, then compose a trigger and content. Use asChild so your own element (like a Button or Icon Button) becomes the trigger:

<TooltipProvider>
  <Tooltip>
    <TooltipTrigger asChild>
      <Button variant="tertiary">Hover me</Button>
    </TooltipTrigger>
    <TooltipContent>
      <p>This is a tooltip</p>
    </TooltipContent>
  </Tooltip>
</TooltipProvider>

TooltipProvider shares timing (open/close delays) across all tooltips within it, so place one high in your tree rather than wrapping each tooltip individually.

Default

Placement

Use side and align on TooltipContent to position the tooltip relative to its trigger, and sideOffset to adjust the gap.

<TooltipContent side="right" align="center">
  <p>Shown to the right</p>
</TooltipContent>

Slots

NameDescription
TooltipProviderShares hover/focus timing across the tooltips it wraps. Place one near the root.
TooltipThe root for a single tooltip, wrapping its trigger and content.
TooltipTriggerThe element that shows the tooltip on hover/focus. Use asChild for your own element.
TooltipContentThe floating hint. Owns placement, offset, and the arrow.

Props

The parts forward their Radix Tooltip props (and className). The most commonly used are below.

NameApplies toDescriptionTypeDefault
sideTooltipContentPreferred side of the trigger to render on.top, right, bottom, lefttop
alignTooltipContentAlignment against the trigger.start, center, endcenter
sideOffsetTooltipContentDistance in pixels between the tooltip and the trigger.number4
asChildTooltipTriggerRender the trigger as the child element instead of a button.booleanfalse
delayDurationTooltipProviderDelay in ms before the tooltip opens on hover.number700