Skip to content
Signal

Components

Tooltip

A short hint on hover or focus: add data-tooltip to any element with .ct-tooltip.

Live example

Rendered with the real classes from /site/chitransit.css, light (left) and dark (right).

.ct-tooltip [data-tooltip]

Code

<button class="ct-button ct-button--sm ct-tooltip is-visible" data-tooltip="Updated 15 s ago">Hover me</button>

Tokens

From tokens/components.tokens.json. Override one instance by setting the property without the ct- prefix.

Custom propertyValueAlias
--ct-tooltip-backgroundvar(--live-bg){colors.liveBg}
--ct-tooltip-colorvar(--live-ink){colors.liveInk}
--ct-tooltip-durationvar(--motion-control-duration){motion.controlDuration}
--ct-tooltip-font-sizevar(--fs-cap){type.cap}
--ct-tooltip-font-weightvar(--weight-semibold){weight.semibold}
--ct-tooltip-max-width240px
--ct-tooltip-offsetvar(--space-6){space.s6}
--ct-tooltip-padding-xvar(--space-8){space.s8}
--ct-tooltip-padding-yvar(--space-4){space.s4}
--ct-tooltip-radiusvar(--radius-chip){radius.chip}

Usage

Do

  • Use a tooltip for a short hint on hover or focus, such as when data was updated.

Don't

  • Don't hide essential information in a tooltip; touch users may never see it.

Accessibility

  • The tooltip text comes from data-tooltip; repeat anything essential in the accessible name.