Skip to main content
The Tooltip component displays additional information when users hover over or focus on an element.

Basic usage

<button flxTooltip="This is a tooltip">
  Hover me
</button>

Properties

flxTooltip
string
required
Tooltip content to display
tooltipPosition
'top' | 'bottom' | 'left' | 'right' | 'auto'
default:"top"
Position of the tooltip relative to the element
tooltipDelay
number
default:"200"
Delay in milliseconds before showing tooltip
tooltipDisabled
boolean
default:"false"
Disables the tooltip
tooltipClass
string
Custom CSS class for the tooltip
tooltipShowOnClick
boolean
default:"false"
Show tooltip on click instead of hover

Examples

<button flxTooltip="Save your changes">
  Save
</button>

<span flxTooltip="This field is required">
  Username *
</span>

<flx-icon
  name="info"
  flxTooltip="Click for more information">
</flx-icon>

Custom styling

<button
  flxTooltip="Custom styled tooltip"
  tooltipClass="custom-tooltip">
  Hover me
</button>
.custom-tooltip {
  background: #1e293b;
  color: #f1f5f9;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

Default styling

flx-tooltip {
  --flx-tooltip-background: #1f2937;
  --flx-tooltip-color: #ffffff;
  --flx-tooltip-font-size: 12px;
  --flx-tooltip-padding: 6px 12px;
  --flx-tooltip-border-radius: 4px;
  --flx-tooltip-max-width: 200px;
  --flx-tooltip-z-index: 1000;
  --flx-tooltip-arrow-size: 6px;
}

Accessibility

The Tooltip component ensures accessibility:
  • role="tooltip" for proper semantics
  • aria-describedby links tooltip to trigger element
  • Shows on focus for keyboard users
  • Dismisses on Escape key
  • Screen reader compatible
  • Respects prefers-reduced-motion

Best practices

  • Keep tooltip text concise (under 2 sentences)
  • Use for supplementary information, not critical content
  • Don’t hide important instructions in tooltips
  • Ensure tooltips don’t cover interactive elements
  • Use consistent positioning within sections
  • Add delays to prevent accidental triggers
  • Don’t use tooltips on mobile (use click instead)
  • Provide keyboard access (show on focus)
  • Use auto position for edge detection
For complex or lengthy explanations, consider using a popover or modal instead of a tooltip.
Never put critical information or actions in tooltips. They should enhance understanding, not be required for basic functionality.

When to use tooltips

Good use cases:
  • Icon button labels
  • Abbreviated text expansion
  • Form field hints
  • Disabled button explanations
  • Feature descriptions
  • Supplementary information
Avoid tooltips for:
  • Critical instructions
  • Error messages
  • Primary actions
  • Mobile interfaces
  • Long-form content
  • Interactive content

Tooltip vs other components

ComponentUse case
TooltipBrief, supplementary information on hover
PopoverRich content with interactions
MessagePersistent in-page alerts
ToastTemporary notifications
ModalCritical information requiring action
  • Message - For persistent contextual messages
  • Icon - Often paired with tooltips
  • Button - Common tooltip trigger

Build docs developers (and LLMs) love