Skip to content

Tooltip

The Tooltip component displays supplemental information in a small popup anchored to a trigger element. It uses the Popover API together with CSS Anchor Positioning, so placement and fallback behavior are handled by the browser.

Use the Tooltip component when you need to:

  • Explain icon-only controls
  • Add short contextual guidance near an action
  • Clarify labels or terms without cluttering the UI
  • Show non-critical, supplementary content
Your current billing and plan status.

Learn how to implement the Tooltip component in your project, from simple helper text to positioned variants.

---
import { Tooltip } from 'accessible-astro-components'
---
<Tooltip id="tooltip-help" triggerLabel="More information">
Profile
<span slot="tooltip">This is the name visible to other users.</span>
</Tooltip>
<Tooltip id="tooltip-right" position="right" triggerLabel="Open help">
Help
<span slot="tooltip">This tooltip appears on the right when possible.</span>
</Tooltip>
<Tooltip id="tooltip-icon" triggerLabel="Learn more about notifications">
<span aria-hidden="true">Notifications</span>
<span slot="tooltip">Choose when and how you receive updates.</span>
</Tooltip>

Configure the Tooltip component with these available props.

PropTypeDefaultDescription
idstring-Unique ID used to connect trigger and tooltip
position'top' | 'bottom' | 'left' | 'right''top'Preferred tooltip position
offsetstring'var(--space-2xs)'Distance between trigger and tooltip
triggerLabelstringundefinedScreen reader label for icon-only or unclear trigger text
showIconbooleantrueShow or hide the default help icon
classstringundefinedAdditional wrapper classes

Accessibility is built into the component through semantic trigger markup and descriptive relationships:

  • Semantic <button> trigger for keyboard interaction
  • aria-describedby linking trigger and tooltip text
  • role="tooltip" on the popup content
  • Preserved focus visibility from native button behavior
  • Reduced motion support through prefers-reduced-motion

Make the Tooltip component your own while preserving readability and contrast.

The component exposes CSS custom properties for spacing and animation behavior:

  • --tooltip-offset
  • --transition-duration
  • --transition-easing
  • --translate-offset-x
  • --translate-offset-y

You can provide a custom class via the class prop and override styles using global selectors in your project stylesheet.

See the Tooltip component in action with common usage patterns.

Tooltip on top (default). Tooltip prefers the right side. Tooltip prefers the left side. Tooltip prefers the bottom side.