Skip to content

Tooltip

A floating label that appears when its trigger is hovered or focused. The trigger goes inside a data-ts-tooltip-root, and the short text in a data-ts-tooltip element with role="tooltip".

Overlays · TaishoDS Core, in plain HTML.

Examples

One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.

Explanation on hover over “Save”

Saves automatically
html

Class reference

Every value of each modifier, with its HTML ready to copy.

Placement

The tooltip’s preferred position relative to the trigger (it flips if there’s no room). Hover or focus each one to see it.

Production · Ready Production · Ready Production · Ready Production · Ready
html

When to use

  • Naming a control that only shows an icon.
  • Clarifying a value or an abbreviation without taking up space in the interface.
  • What you’re saying is supplementary. If nobody reads it, nothing is lost.

When not to use

  • The information is required to complete the task → make it visible (for example, the field hint, ts input-hint).
  • People need to click inside it → popover.
  • It’s actions on an object → menu.

Do

  • Short text, one line. It’s a label, not documentation.
  • For an icon-only button, give it its aria-label in addition to the tooltip.

Don’t

  • Don’t hide what the user needs in it. Touch screens have no hover.
  • Don’t put links or buttons inside—they can’t be reached.

TaishoDS Core

Needs Core’s JS, which hooks in through data-ts-* attributes.

It’s shown with the Popover API, but positioning and delays are Core’s own.

Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.

  • data-ts-placement
  • data-ts-tooltip
  • data-ts-tooltip-root

What it does: Show and hide delays, and positioning. Next to the viewport edge, it keeps the same margin as its offset from the trigger (6 px).

From the CDN, without a build, load taisho.tooltip.css along with taisho.base.css. That file is all you need.

For how Core works in general, see Behavior.

Accessibility

Implements the Tooltip pattern from the WAI-ARIA APG.

  • It shows on both hover and keyboard focus, and hides with Esc. On keyboard focus it appears immediately; with the pointer, after 150 ms. There is no touch trigger: a tap may not show it, so nothing essential should depend on it.
  • The tooltip describes the trigger: when the component is prepared, Core puts aria-describedby on the first focusable element inside data-ts-tooltip-root (the button or link), not on the wrapper. If none is focusable, it stays on the wrapper and announcing it is not guaranteed. Without Core’s JS, the markup carries no aria-describedby, so the tooltip doesn’t describe the trigger.
  • When the pointer leaves, the tooltip waits 100 ms before closing and accepts the pointer over it, so it can be read without disappearing (WCAG 1.4.13: dismissible and hoverable). If focus stays on the trigger and the pointer leaves, it still closes after 100 ms. It closes with no delay when focus is lost.
  • The trigger must be a focusable element (a button or link) for the tooltip to be keyboard accessible.
  • Next to the viewport edge, the tooltip shifts so it doesn’t get clipped, with a margin (quarter), so the text stays whole and readable on narrow screens.

Keyboard

On top of what the browser already does (Tab moves focus, Enter activates a button).

Key What it does
EscCloses the visible tooltip, whether focus is on the trigger or elsewhere. The key is consumed: a modal or menu underneath closes with the next Esc.

Verification

What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.

  • axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
  • keyboard Key map documented above, checked against the component.
  • screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.