react-tooltip

A lightweight, accessible React tooltip component with automatic Floating UI-powered positioning.

Library
npm
v6.0.9
3,826 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
78 /100 Good
Development Activity 68
Maintenance 72
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 78
Code Quality 85
Innovation 55
Learning Curve 90

React Tooltip is a customizable tooltip component for React applications. It lets you attach contextual popovers to any DOM element through simple data-tooltip-* attributes or an imperative React API, renders through a portal, and supports rich HTML/JSX content or plain text. Positioning is computed automatically using Floating UI middleware (flip, shift, arrow) so tooltips reposition themselves to stay within the viewport regardless of where the anchor sits on the page.

Now in its v6 release, the library supports React 16.14 through 19, including apps using React Server Components (the Tooltip itself must render inside a client boundary). It ships a shared document-level event delegation system that keeps listener counts low even with many tooltips on one page, plus controlled and uncontrolled visibility modes, configurable show/hide delays, click-to-open behavior, and a render prop for building tooltip content dynamically from the active anchor.

What You Get

  • Declarative <Tooltip> component with a data-tooltip-id/data-tooltip-content attribute API for zero-boilerplate usage
  • Floating UI-powered positioning with automatic flip/shift/arrow middleware to keep tooltips on-screen
  • Controlled and uncontrolled visibility modes via isOpen/setIsOpen or built-in open/close event handling
  • A render prop for fully custom tooltip content driven by the active anchor element
  • Shared document-level event delegation so many tooltips on one page stay cheap in listener count
  • Full TypeScript typings shipped in the package (dist/react-tooltip.d.ts)

Common Use Cases

  • Icon-only UI buttons that need an accessible text label on hover/focus
  • Form field help text and validation hints shown next to inputs
  • Dashboard and data-table cells with truncated values that reveal the full value on hover
  • Onboarding/product tours that point out a specific control with contextual copy
  • Disabled-button explanations telling users why an action isn’t available

Under The Hood

Architecture

The public Tooltip export (TooltipController.tsx) is a thin normalization layer: it reads live data-tooltip-* attributes off the currently active anchor (tracked via anchor-registry.ts and a MutationObserver-based shared-attribute-observer.ts), merges them over the component’s props with data-attributes taking priority, and hands the resolved config down to the inner Tooltip component. Positioning is delegated to compute-tooltip-position.ts, a wrapper around @floating-ui/dom’s computePosition with hoisted flip/shift middleware and an optional arrow middleware. A separate event-delegation.ts module maintains exactly one document-level listener per event type/capture-phase combination and fans events out to all registered tooltip instances, turning what would be O(N tooltips x M event types) listeners into O(M). The three concerns — anchor tracking, position math, and global event plumbing — are cleanly separated into their own modules.

Tech Stack

Written in TypeScript against React 19 (peer range >=16.14.0 for both react and react-dom), with only two runtime dependencies: @floating-ui/dom for position computation and clsx for conditional class names. The build pipeline uses esbuild for the dev server (esbuild.config.dev.mjs) and Rollup for production (rollup.config.prod.mjs, rollup-plugin-dts for bundled type declarations, rollup-plugin-terser for minification, rollup-plugin-postcss for CSS Modules), publishing dual CJS/ESM builds through a conditional exports map. A prebuild.js script performs environment-specific codegen before bundling.

Code Quality

The src/test/ directory holds an extensive Jest suite (13+ spec files covering interactions, controlled/ref usage, imperative APIs, observers, styling, attribute resolution, and edge cases), run under jest-environment-jsdom with @testing-library/react and coverage collected via the V8 provider. Linting combines eslint-config-airbnb, eslint-plugin-jsx-a11y, and eslint-plugin-react-hooks, enforced through Husky pre-commit hooks and lint-staged, with CI configured via both .travis.yml and GitHub Actions workflows.

What Makes It Unique

The shared document-level event delegation system is a comprehensive alternative to the more common per-instance listener pattern seen in similar tooltip libraries, keeping pages with many simultaneous tooltips lighter on memory and event-dispatch overhead. Beyond that, the library’s core interaction model — resolving tooltip behavior from live DOM data-attributes rather than requiring a JS-side configuration object per anchor — is a well-executed but by-now standard pattern within the React tooltip ecosystem rather than a genuinely novel technique.

Used by 11 apps in this directory

JavaScript
99%
MIT

AnythingLLM

AI Assistants · Automation · Developer Tools

67,496

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
65
Dependency
Built with
JavaScript 99%
Updated yesterday
Rust
56%
Other

Cap

Team Chat · Video Conferencing

23,609

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 56%
TypeScript 38%
Updated yesterday
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,303

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
66
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 3 days ago
Python
63%
BSD 3

Flagsmith

Ab Testing Experimentation · Developer Tools · Devops

6,613

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
90
Repo Health
82
Technical
63
Dependency
Built with
Python 63%
TypeScript 32%
Updated yesterday
TypeScript
77%
Other

Joplin

Note Taking

56,853

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 2 days ago
TypeScript
87%
MIT

medusa

Ecommerce

36,897

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
94
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 87%
JavaScript 12%
Updated 2 days ago
JavaScript
90%
Other

OpenSign

Digital Signiture

7,163

Self-host a full-featured DocuSign alternative with unlimited e-signatures, multi-signer workflows, and cryptographic PDF signing.

View details
83
Repo Health
61
Technical
69
Dependency
Built with
JavaScript 90%
Updated 2 days ago
TypeScript
81%
AGPL 3.0

Postiz

Automation · Social Media

37,683

The agentic social media scheduler — AI-powered content creation, 33-platform posting, and team workflows, all self-hosted.

View details
92
Repo Health
70
Technical
63
Dependency
Built with
TypeScript 81%
JavaScript 11%
Updated 2 days ago
JavaScript
50%
AGPL 3.0

QRev

AI Agents · CRM

364

Open source AI-first sales platform that replaces Salesforce with autonomous agents handling prospecting, outreach, and lead management at scale.

View details
39
Repo Health
68
Technical
64
Dependency
Built with
JavaScript 50%
Python 28%
TypeScript 14%
Updated 8 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers