Skip to content
Fleetline

Tooltip

Usage

Use a tooltip to name an icon-only button ("Schedule service") or add one short supplemental fact ("Synced from telematics 4 minutes ago"). It appears on hover and on keyboard focus.

Anatomy

  1. Trigger — a focusable element with aria-describedby (or aria-labelledby for icon buttons) and data-tooltip-trigger
  2. Bubble — <div class="tooltip" popover="hint" role="tooltip">, inverse surface, one line of text

Examples

Tooltip

Hover or Tab to the button: the tooltip appears after 400ms. Press Esc to hide it without moving focus.

<!-- Icon button: the tooltip IS the accessible name -->
<button type="button" class="btn btn--ghost" aria-labelledby="tt-schedule" data-tooltip-trigger="tt-schedule">
  <svg class="btn__icon" aria-hidden="true" focusable="false"><use href="#icon-calendar"></use></svg>
</button>
<div id="tt-schedule" class="tooltip" popover="hint" role="tooltip">Schedule service</div>

<!-- Supplemental hint -->
<button type="button" class="btn btn--secondary btn--sm" aria-describedby="tt-odo" data-tooltip-trigger="tt-odo">Odometer 85,200 km</button>
<div id="tt-odo" class="tooltip tooltip--block-end" popover="hint" role="tooltip">Synced from telematics 4 minutes ago</div>

<script type="module">import { init } from "../js/tooltip.js"; init();</script>

API

HookValuesPurpose
.tooltip[popover="hint"][role="tooltip"]blockBubble; hint falls back to manual where unsupported
.tooltip--block-end | --inline-start | --inline-endmodifierPreferred placement (default above)
data-tooltip-trigger="id"attributeWires hover/focus/Esc behavior in js/tooltip.js
aria-describedby | aria-labelledbyattributeSupplemental description, or the name of an icon-only button
init(root)JSEnhances every trigger in root; safe to call twice
.is-opendocs-only classVisible tooltip in page flow (same rule as :popover-open)

Do and don't

Schedule service
Do keep it to a few words that name or clarify.
Vehicle KX-24 is overdue. Click here to open the service planner and book a slot.
Don't put instructions, links or essential warnings in a tooltip. Use an alert.

Accessibility

Keyboard interaction
KeyBehavior
TabFocusing the trigger shows the tooltip after 400ms; leaving hides it
EscHides the tooltip; focus stays on the trigger (inside a dialog, only the tooltip closes)

Tokens

Custom propertyPurpose
--color-bg-inverse, --color-text-inverseBubble colors
--radius-sm, --shadow-mdShape and lift
--font-size-xs, --font-weight-mediumText
--space-1-5 | -2Padding and gap to trigger
--motion-duration-fastFade