Skip to content

feat(react): add the Tooltip primitive#8

Open
ivanbanov wants to merge 2 commits into
mainfrom
feat/tooltip
Open

feat(react): add the Tooltip primitive#8
ivanbanov wants to merge 2 commits into
mainfrom
feat/tooltip

Conversation

@ivanbanov

Copy link
Copy Markdown
Member

Summary

Adds the Tooltip primitive as two packages:

  • @dunky.dev/tooltip — the framework-free core: a state machine implementing the WAI-ARIA APG tooltip pattern (open/close orchestration, delays, grace period) plus the connect that exposes parts, events, and reactions.
  • @dunky.dev/react-tooltip — the thin React binding: a compound Tooltip component wired through useMachine, adding no behavior of its own.

A tooltip is a hover/focus description popup: it labels its trigger with contextual text, opens on intent, and never traps focus. Positioning stays with the consumer in v0.

Anatomy

  • Tooltip — root; holds config (openDelay, closeDelay, onOpenChange) and context.
  • Tooltip.Trigger — the element the tooltip describes; carries aria-describedby while visible.
  • Tooltip.Portal — renders the content into document.body (or a custom container).
  • Tooltip.Content — the popup itself (role="tooltip").

Behavior

  • Hover opens after openDelay (700 ms default) and closes after closeDelay (300 ms default); re-entering the trigger or the content while closing keeps it open (grace period).
  • Keyboard focus opens immediately; blur closes immediately.
  • Escape and pressing the trigger — by pointer or keyboard activation (Enter/Space) — close immediately.
  • Content has role="tooltip" and is linked to the trigger via aria-describedby; every part carries data-state (closed/opening/open/closing) as the styling and animation hook.

Test plan

  • pnpm test:ci — 119 tests, 9 files, all passing
  • pnpm typecheck
  • pnpm lint
  • pnpm format:check
  • pnpm build

🤖 Generated with Claude Code

ivanbanov and others added 2 commits July 18, 2026 10:40
Adds @dunky.dev/tooltip (core machine) and @dunky.dev/react-tooltip
(React binding) with the Tooltip, Tooltip.Trigger, Tooltip.Portal, and
Tooltip.Content anatomy.

Hover opens after a delay and closes after a grace delay; focus opens
immediately; blur, Escape, and trigger press close immediately — with
data-state exposed on every part for styling.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ivanbanov ivanbanov changed the title feat: add the Tooltip primitive feat(react): add the Tooltip primitive Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant