Tooltip

Contextual help text that appears on hover or focus. Perfect for explaining icons, truncated text, or providing additional context.

Setup

import { Tooltip } from '@fragments-sdk/ui';

Examples

Default

Basic tooltip on hover

Loading preview...

Positions

Tooltips on different sides

Loading preview...

With Shortcut

Tooltip showing keyboard shortcut

Loading preview...

No Arrow

Tooltip without arrow

Loading preview...

With Content Props

Pass popup attributes/styling using contentProps

Loading preview...

Props

PropTypeDefaultDescription
childrenRequiredelementNot setThe element that triggers the tooltip
contentRequirednodeNot setContent to display in the tooltip
sideenumtopbottomleftrighttopWhich side to show the tooltip
alignenumstartcenterendcenterAlignment along the side
sideOffsetnumber6Distance from trigger in pixels
delaynumber400Delay before showing (ms)
closeDelaynumber0Delay before hiding (ms)
disabledbooleanfalseDisable the tooltip
arrowbooleantrueShow arrow pointing to trigger
openbooleanNot setControlled open state
defaultOpenbooleanfalseDefault open state
onOpenChangefunctionNot setCallback when open state changes
closeOnClickbooleanfalseWhether clicking the trigger closes the tooltip.
contentPropsobjectNot setProps forwarded to the tooltip popup element (preferred way to pass popup attrs/className/style)
styleobjectNot set

Usage Guidelines

When to use

  • Explaining icon-only buttons
  • Showing full text for truncated content
  • Providing keyboard shortcuts
  • Brief contextual help that fits in one line

When not to use

  • Long-form help content (use Popover)
  • Critical information users must see (use Alert)
  • Interactive content (use Popover or Menu)
  • Mobile-primary interfaces (tooltips require hover)

Best practices

  • Keep tooltip text concise (under 80 characters)
  • Use sentence case, no period for single sentences
  • Avoid duplicating visible label text
  • Consider mobile users who cannot hover
  • Use contentProps for tooltip popup attributes/styling; top-level HTML attrs are applied to the popup for backward compatibility
Accessibility
  • Accessible via focus as well as hover
  • Uses role="tooltip" with proper aria association
  • Delay prevents tooltips from appearing during navigation