Skip to main content

Tooltip

A short hint on hover or focus.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Explains an icon button.

  • Use it when: A brief name or hint for a control that already has an accessible name.
  • Not when: The only place values or important words live, or touch screens, where hover never happens.

Instead:

How Dense data uses it​

An icon with no label
Use Icon button with a tooltip
Not A bare icon
Experts learn icons; the tooltip covers the first uses.

Words​

  • Lead with the object, then the state: "Alert 2041 contained."
  • Use numbers, not words for numbers.
  • One verb per button. No "please", no exclamation marks.
  • Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedEscape hides it.undefined

Test before you ship:

  • It describes its trigger and also shows on keyboard focus. undefined

Use it in code​

npx open-ds add tooltip

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Tooltip reads 7 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Tooltip's tokens to change Tooltip alone.

Changes with theme

Dense data decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Tooltip
Fill
Changes with theme
component.tooltip.backgroundcolor.surface.inversevar(--tooltip-background)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Text
Changes with theme
component.tooltip.labelcolor.text.inversevar(--tooltip-label)Lightslate.light.0:#FFFFFFDarkslate.light.900:#161B23
Content
Cornercomponent.tooltip.content.radiusradius.badgevar(--tooltip-content-radius)radius.0:0rem
Padding, left and rightcomponent.tooltip.content.padding-xspace.gap.defaultvar(--tooltip-content-padding-x)space.8:0.5rem
Padding, top and bottomcomponent.tooltip.content.padding-ycomponent-spacing-map.x1var(--tooltip-content-padding-y)space.4:0.25rem
Text sizecomponent.tooltip.content.font-sizetype.caption.font-sizevar(--tooltip-content-font-size)font.size.12:0.75rem
Font familycomponent.tooltip.content.font-familytype.caption.font-familyvar(--tooltip-content-font-family)font.family.ibm-plex-sans:"IBM Plex Sans", system-ui, sans-serif