Tooltip

Atom

Contextual hint that appears near a UI element on hover or focus. Mirrors Figma node 140-7707 (light) + 2289-4036 (dark) 1:1. The tooltip inverts between modes — dark pill + light text in light mode, light pill + dark text in dark mode — always contrasting with the page surface. Three sizes (Large 40 px / Medium 32 px / Small 24 px) × four arrow positions. For live usage wrap the trigger + tooltip in .tooltip-host; the tooltip hides at rest and fades in on hover/focus-within via pure CSS.

When to use

✅ Do
  • Use for supplementary hints on icon-only buttons where no visible label is present
  • Use for truncated text that needs full-text disclosure on hover
  • Keep tooltip text to a single short phrase — 1–8 words
  • Use .tooltip-host for hover/focus-triggered show without JavaScript
❌ Don't
  • Put critical information in a tooltip — it is invisible by default
  • Use on mobile — hover doesn't exist on touch devices
  • Repeat visible label text — tooltips add context, not duplicates
  • Use for long descriptions — use a popover or inline text instead

DigiLawyer Patterns

No specific DigiLawyer patterns documented yet — to be added.

Anatomy

A Tooltip is a pill that inverts between light and dark mode. The arrow caret is rendered via CSS pseudo-elements.

Tooltip text
  1. 1Pill.tooltip. Inverts between modes: dark in light, light in dark.
  2. 2Arrow caret::before (border) + ::after (fill). Direction set by position modifier.
  3. 3Position.tooltip-top/bottom/left/right. Controls which side the arrow appears on.
  4. 4Icon slot.tooltip-icon. Optional leading icon, scales with size modifier.
  5. 5Host wrapper.tooltip-host. CSS-only show/hide on hover and focus-within. No JS needed.

Default

A bare .tooltip at the Large (default) size. No arrow is shown standalone — add a positional class (.tooltip-top etc.) to get the caret.

Lorem ipsum dolor sit amet.

Interactive

Hover any button below to see the live tooltip. Uses .tooltip-host (position relative wrapper) + absolute child .tooltip.tooltip-{position}. No JavaScript — the caret and fade are pure CSS. Each position offsets the tooltip by calc(100% + 8px) from the trigger edge.

Tooltip appears above Top
Tooltip appears below Bottom
Tooltip appears right Right
Tooltip appears left Left

Sizes

Three sizes mapped 1:1 to Figma's symbol names. Default .tooltip is Large (40 px, Body 2 14/24 Medium). .tooltip-md is Medium (32 px, Caption 1 12/16). .tooltip-sm is Small (24 px, Caption 2 10/12). Horizontal padding is --spacing-sm (12 px) for lg/md and --spacing-xs (8 px) for sm.

Large · 40
Lorem ipsum dolor sit amet.
Medium · 32
Lorem ipsum dolor sit amet.
Small · 24
Lorem ipsum dolor sit amet.

Positions

Four positions — the class name indicates where the tooltip appears; the arrow points back toward the trigger. Shown at Large / Medium / Small per row. In production, combine position + size on the same element: class="tooltip tooltip-md tooltip-top".

Top — tooltip above trigger (arrow at bottom)
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Bottom — tooltip below trigger (arrow at top)
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Right — tooltip to the right (arrow at left)
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Left — tooltip to the left (arrow at right)
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.

Full matrix

4 positions × 3 sizes. Toggle the theme switch to confirm the dark-mode inversion: pill flips to #F6F6F6 bg + #2D2D2D text on the dark surface.

Accessibility

Attribute / BehaviourValueNotes
Tooltip rolerole="tooltip"Set on the tooltip element so screen readers identify it
Trigger associationaria-describedby="tooltip-id"Link the trigger element to the tooltip via its ID
Keyboard — showOn focus of the triggerTooltip must appear when the trigger receives keyboard focus, not only on hover
Keyboard — hideEscAlways allow dismissing the tooltip with Escape
TouchNot supportedTooltip is hover/focus only. For mobile, include the info inline or in a tap-accessible popover

API

Class / attrOnDescription
.tooltip<span>Base pill. Large (40 px, Body 2 14/24 Medium). Dark bg + light text in light mode; inverts in dark mode. position: relative for the arrow pseudo-elements.
.tooltip-md.tooltipMedium — 32 px tall, Caption 1 (12/16) Medium.
.tooltip-sm.tooltipSmall — 24 px tall, Caption 2 (10/12) Medium. Padding reduces to 6px 8px.
.tooltip-top.tooltipArrow at the pill's bottom pointing down → tooltip appears above the trigger.
.tooltip-bottom.tooltipArrow at the pill's top pointing up → tooltip appears below.
.tooltip-right.tooltipArrow at the pill's left pointing left → tooltip appears to the right.
.tooltip-left.tooltipArrow at the pill's right pointing right → tooltip appears to the left.
.tooltip-icon<span> inside .tooltipLeading / trailing icon slot. SVG scales 16 / 14 / 12 px with the parent size.
.tooltip-host<span> / <div> wrapping trigger + tooltipInteractive wrapper. position: relative. The child tooltip is absolutely positioned and hidden at rest (opacity: 0); it fades in on :hover or :focus-within without JavaScript. Combine with a positional class on the tooltip for offset placement.
--tooltip-bgToken#2D2D2D light / #F6F6F6 dark — inverts to contrast with the page.
--tooltip-textToken#F6F6F6 light / #2D2D2D dark.
--tooltip-borderTokenrgba(255,255,255,0.10) light / rgba(0,0,0,0.10) dark — subtle 10% hairline.