Skip to main content

Tooltip

Contextual labels that appear when hovering an element. Uses the data-tooltip attribute โ€” no wrapper components or JavaScript required for basic usage.

Preview ยท Tooltip

Codeโ€‹

<!-- Add data-tooltip to any element -->
<button data-tooltip="Save all pending changes">Save</button>

<!-- Below position -->
<span data-tooltip="Your unique tenant ID" data-tooltip-pos="bottom">Tenant ID</span>

<!-- On badges -->
<span class="badge warning" data-tooltip="Trial expires in 7 days">Trial</span>

<!-- On disabled buttons (explain why disabled) -->
<button disabled data-tooltip="Requires Admin role">Delete tenant</button>

<!-- Long tooltip text wraps automatically -->
<button data-tooltip="This action will permanently delete the tenant and all associated data. This cannot be undone.">
Delete
</button>

API Referenceโ€‹

data-tooltipโ€‹

AttributeValueDescription
data-tooltipstringTooltip text. Appears on hover/focus.
data-tooltip-pos'top' (default) | 'bottom' | 'left' | 'right'Position relative to the element

Auto-conversionโ€‹

When the @primus/ui-core JS bundle loads, any existing title attributes are automatically converted to data-tooltip โ€” so legacy title="..." patterns will work too.

<!-- These are equivalent after the JS bundle loads -->
<button title="Save changes">Save</button>
<button data-tooltip="Save changes">Save</button>

When to useโ€‹

Use tooltip forDon't use tooltip for
Clarifying icon-only buttonsCritical information (use inline text instead)
Explaining disabled statesLong instructions โ€” use a popover or help text
Showing full values that are truncatedMobile-primary interactions (hover doesn't exist)
Abbreviation expansionsError messages (use role="alert" instead)
Version history

See the Changelog for version history and breaking changes.