Skip to content

Component: Tooltip #13

Closed
Closed

Description

@coloneljade

Summary

Add a Tooltip component for contextual information on hover/focus.

Justification

Tooltips have subtle a11y and UX requirements:

  • `aria-describedby` association with trigger element
  • Show on hover and focus, hide on blur and Escape
  • Positioning logic (avoid viewport overflow)
  • Touch device considerations

Acceptance Criteria

  • Shows on hover and focus
  • Hides on blur, mouse leave, and Escape
  • `aria-describedby` links trigger to tooltip content
  • Positions without clipping viewport
  • Tests cover keyboard trigger and ARIA association

References

Standards and accessibility

Popover API (current implementation target)

Future CSS (not yet cross-browser — revisit when Baseline)

Activity

  1. added
    enhancement
    on Feb 25, 2026
  2. coloneljade commented on Mar 14, 2026

    @coloneljade
    OwnerAuthor

    Research notes (pre-implementation)

    A few things surfaced during planning worth capturing.

    Popover API

    We'll use `popover="hint"` for rendering. Main benefit: top-layer placement means no z-index management needed, tooltips escape any overflow/stacking context issues in the consuming app, and Escape dismissal is handled by the browser natively.

    The caveat: the CSS ecosystem around this isn't mature yet. Two pieces that would make the implementation fully declarative are not ready:

    • CSS Anchor Positioning (Chrome/Edge only) — would let us skip the `getBoundingClientRect()` positioning math entirely
    • Interest Invokers (proposal stage) — would let CSS drive hover/focus triggering without JS event listeners

    Until those land cross-browser, we wire our own `mouseenter`/`mouseleave`/`focusin`/`focusout` listeners and compute placement via `getBoundingClientRect()` + CSS custom properties (same pattern as `useDraggable`). Not a problem, just more JS than we'd ideally write.

    Configurable delay

    Removed from scope. WCAG 1.4.13 requires tooltips to be persistent (not auto-hide on a timer), and a show delay creates more problems than it solves (flicker, missed interactions). We'll show immediately on hover/focus.

    Viewport overflow / repositioning

    Not in scope for the initial implementation. We'll pick a `placement` and render there. Auto-flipping when the tooltip would clip the viewport is a nice-to-have but adds meaningful complexity; can be tracked separately if needed.

    Touch devices

    No good solution exists. Hover doesn't apply, and focus activates interactive elements rather than showing tooltips. We'll document this as a known limitation — the component will work on touch via focus, but the experience is degraded. This is an industry-wide unsolved problem.

    Content is always a string

    Rich/interactive tooltip content is out of scope by design. If you need interactive content, use Dialog instead. This keeps the implementation simple and prevents misuse.

  3. coloneljade commented on Mar 14, 2026

    @coloneljade
    OwnerAuthor

    Pausing tooltip implementation — CSS Anchor Positioning and the Interest Invokers proposal are not yet cross-browser Baseline. Will revisit when both land in Baseline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions