Skip to content

Tooltip

BetaData displayOpen in the workshop

A short label for an icon button or a truncated value, on hover and focus.

.xg-tooltip > trigger + .xg-tooltip__bubble[role=tooltip]

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

Tooltip
Download as CSVRevenue per 1,000 impressions
Markup
<div class="xg-row" style="padding-top:36px">
<span class="xg-tooltip is-open">
<button class="xg-btn xg-btn--secondary xg-btn--icon" type="button" aria-label="Download report" aria-describedby="tt1">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 4v11"/>
<path d="m7 10 5 5 5-5"/>
<path d="M4 20h16"/>
</svg>
</button>
<span class="xg-tooltip__bubble" role="tooltip" id="tt1">Download as CSV</span>
</span>
<span class="xg-tooltip">
<button class="xg-btn xg-btn--ghost xg-btn--sm" type="button" aria-describedby="tt2">eCPM <svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<circle cx="12" cy="12" r="9"/>
<path d="M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6v.6"/>
<path d="M12 17h.01"/>
</svg>
</button>
<span class="xg-tooltip__bubble" role="tooltip" id="tt2">Revenue per 1,000 impressions</span>
</span>
</div>

States

Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.

Tooltip: every state
StateTooltip
HiddenDownload as CSV
Shown (hover or focus)Download as CSV

When to use it

Use it for

naming icon-only buttons; explaining a metric in a table header.

Not for

anything essential or interactive (use a Popover or put it on the page).

Rules

  • One line, no period, under about 80 characters.
  • Appears on hover and on keyboard focus; never on click only.

Accessibility

  • The trigger references the bubble with aria-describedby. Text on surface-inverse passes 4.5:1.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Data display: Data table, Pagination, KPI card, Status badge, Tag, Avatar, Progress, Chart, Empty state, Skeleton, Spinner.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).