react-tippy is a React wrapper for the popular tippy.js tooltip library, leveraging Popper.js for precise positioning. Currently at version 1.4.0, it provides a lightweight and flexible way to integrate tooltips into React applications. The library offers both a <Tooltip> component for declarative usage and a withTooltip higher-order component (HOC) for more advanced scenarios, such as wrapping existing components. A key differentiator is its use of React DOM to render tooltip content, allowing full access to React features within the tooltip itself, including integration with state management libraries like Redux. TypeScript support was introduced in v1.3.0. While an exact release cadence isn't explicitly stated, the project sees regular maintenance updates for bug fixes and feature enhancements, such as the v1.3.1 release for exception guards.
npm install react-tippyVerified import paths — ran on the pinned version, not inferred.
This code sets up a basic React component displaying a button with a clickable tooltip using `react-tippy`. It demonstrates importing the component, its CSS, and configuring various tooltip props.
Ensure `import 'react-tippy/dist/tippy.css';` is included in your application's entry point or relevant component file.
Update to `react-tippy@^1.3.0` and ensure your project's TypeScript configuration is set up correctly to consume the shipped types. Review any custom type definitions you might have had.
Set `interactiveBorder` to a suitable pixel value (e.g., `interactiveBorder={10}`) to create a buffer zone around the interactive tooltip.Choose between having an arrow (`arrow={true}`) or the fill animation (`animateFill={true}`). They are mutually exclusive.When using `open` and `onRequestClose`, set `trigger='manual'` to prevent automatic behavior from interfering. Ensure your state updates correctly handle both showing and hiding the tooltip via these props.
Ensure you have `import 'react-tippy/dist/tippy.css';` in your code. If using Webpack, ensure you have a CSS loader configured (e.g., `style-loader` and `css-loader`).
Add `import 'react-tippy/dist/tippy.css';` to your application. Check browser developer tools for any CSS errors or overridden styles.
Upgrade `react-tippy` to version `1.3.0` or higher (`yarn upgrade react-tippy` or `npm update react-tippy`). Ensure your `tsconfig.json` includes type definitions if you are not using an auto-configured setup.
Set `interactive={true}` on your `<Tooltip>` component. If using `mouseenter` trigger, also consider increasing `interactiveBorder` (e.g., `interactiveBorder={10}`) to create a larger safe zone.