Skip to content

Tooltip

Hover tooltip component with multiple placements and variants. Automatically repositions when there is not enough space in the preferred direction.

Also known as: popover, hint, hover info, title tooltip, info bubble

View in Storybook

When to use

  • Showing supplementary information on hover (icon explanations, truncated text, shortcuts)
  • For interactive popup menus, use Dropdown instead
  • Supports rich content (ReactNode), not just plain text

Import

tsx
import { Tooltip } from '@vacano/ui'

Usage

tsx
<Tooltip content="This is a tooltip">
  <Button>Hover me</Button>
</Tooltip>

Placements

tsx
<Tooltip content="Top tooltip" placement="top">
  <Button>Top</Button>
</Tooltip>

<Tooltip content="Bottom tooltip" placement="bottom">
  <Button>Bottom</Button>
</Tooltip>

<Tooltip content="Left tooltip" placement="left">
  <Button>Left</Button>
</Tooltip>

<Tooltip content="Right tooltip" placement="right">
  <Button>Right</Button>
</Tooltip>

Variants

tsx
<Tooltip content="Dark tooltip" variant="dark">
  <span>Dark</span>
</Tooltip>

<Tooltip content="Light tooltip" variant="light">
  <span>Light</span>
</Tooltip>

<Tooltip content="Success tooltip" variant="success">
  <span>Success</span>
</Tooltip>

<Tooltip content="Warning tooltip" variant="warning">
  <span>Warning</span>
</Tooltip>

<Tooltip content="Danger tooltip" variant="danger">
  <span>Danger</span>
</Tooltip>

Custom Delay

tsx
// No delay
<Tooltip content="Instant" delay={0}>
  <span>Hover</span>
</Tooltip>

// Longer delay (milliseconds)
<Tooltip content="Delayed" delay={500}>
  <span>Hover</span>
</Tooltip>

Rich Content

tsx
<Tooltip
  content={
    <div>
      <strong>Title</strong>
      <p>Detailed description here</p>
    </div>
  }
>
  <Button>Rich Tooltip</Button>
</Tooltip>

Portal Rendering

For use inside containers with overflow: hidden:

tsx
<Tooltip
  content="Tooltip content"
  portalRenderNode={document.body}
>
  <Button>With Portal</Button>
</Tooltip>

Props

PropTypeDefaultDescription
childrenReactNoderequiredTrigger element that activates the tooltip on hover
contentReactNoderequiredTooltip content (text or JSX)
placement'top' | 'bottom' | 'left' | 'right''top'Preferred tooltip position relative to the trigger. Auto-adjusts if not enough space.
variant'dark' | 'light' | 'success' | 'warning' | 'danger''dark'Color variant
delaynumber200Delay in milliseconds before showing the tooltip on hover
portalRenderNodeHTMLElement | null-When provided, tooltip content is rendered via createPortal into this node
classNamestring-CSS class name for the wrapper element
classnamesTooltipClassNames-Custom class names for sub-elements
refRef<HTMLDivElement>-Ref forwarded to the wrapper element
data-test-idstring-Test identifier attribute

The component also accepts all standard HTMLDivElement attributes (except className and content which are overridden by component props).

TooltipClassNames

KeyDescription
contentTooltip content container (the floating tooltip box)
  • Dropdown - interactive popup menu triggered by click
  • KeysBindings - display keyboard shortcuts (often shown inside tooltips)

Released under the MIT License.