@popperjs/core vs react-popper vs react-tooltip vs react-overlays vs react-popper-tooltip vs react-tippy
React Tooltip and Popover Libraries Comparison
1 Year
@popperjs/corereact-popperreact-tooltipreact-overlaysreact-popper-tooltipreact-tippySimilar Packages:
What's React Tooltip and Popover Libraries?

These libraries are designed to manage tooltips, popovers, and overlays in React applications. They provide developers with the necessary tools to create interactive UI elements that enhance user experience by displaying contextual information when users hover over or click on elements. Each library has its unique features and use cases, making them suitable for different scenarios in web development.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
@popperjs/core12,760,58830,7261.46 MB472 years agoMIT
react-popper4,181,5532,51379.1 kB39-MIT
react-tooltip1,260,4083,673872 kB207 months agoMIT
react-overlays1,124,817899249 kB114-MIT
react-popper-tooltip667,44225093.3 kB7-MIT
react-tippy81,091977-1045 years agoMIT
Feature Comparison: @popperjs/core vs react-popper vs react-tooltip vs react-overlays vs react-popper-tooltip vs react-tippy

Positioning

  • @popperjs/core:

    @popperjs/core offers advanced positioning capabilities, allowing you to position elements relative to other elements with precision. It supports various placement options and can handle dynamic content changes effectively.

  • react-popper:

    react-popper uses the Popper.js engine to provide accurate positioning of tooltips and poppers. It automatically updates the position when the reference element changes, ensuring that tooltips remain aligned with their target.

  • react-tooltip:

    react-tooltip provides basic positioning capabilities, allowing you to specify the position of tooltips easily. However, it may not handle complex positioning scenarios as effectively as others.

  • react-overlays:

    react-overlays provides a flexible positioning system but relies on the developer to manage the positioning logic. It allows for custom overlays but may require more manual handling compared to other libraries.

  • react-popper-tooltip:

    react-popper-tooltip simplifies the positioning of tooltips by wrapping react-popper, making it easy to implement tooltips with correct positioning without much effort.

  • react-tippy:

    react-tippy offers straightforward positioning options with built-in support for various placements. It allows for quick setup and customization of tooltip positions with minimal configuration.

Customization

  • @popperjs/core:

    @popperjs/core is highly customizable, allowing developers to define their positioning logic and styles. It provides hooks for advanced use cases, making it suitable for complex applications.

  • react-popper:

    react-popper provides a good balance of customization options while maintaining simplicity. Developers can easily customize the appearance and behavior of poppers using props and styles.

  • react-tooltip:

    react-tooltip is straightforward to customize, allowing developers to change styles and content easily. It is suitable for projects where quick and simple tooltip implementations are needed.

  • react-overlays:

    react-overlays allows for extensive customization of overlay components, enabling developers to create tailored solutions for their specific needs. It is flexible but may require more effort to implement custom styles.

  • react-popper-tooltip:

    react-popper-tooltip offers limited customization options compared to react-popper, focusing on ease of use. It allows basic styling but is designed for quick implementations rather than extensive customization.

  • react-tippy:

    react-tippy excels in customization, providing a wide range of options for animations, themes, and styles. It is ideal for developers who want visually rich tooltips with various effects.

Accessibility

  • @popperjs/core:

    @popperjs/core does not provide built-in accessibility features, so developers need to implement their own accessibility practices when using it in applications.

  • react-popper:

    react-popper does not include accessibility features by default, but it allows developers to implement their own accessibility practices when integrating poppers into their applications.

  • react-tooltip:

    react-tooltip is designed with accessibility in mind, providing ARIA attributes and keyboard navigation support, making it suitable for applications that need to be accessible.

  • react-overlays:

    react-overlays focuses on accessibility, providing components that are designed to be accessible out of the box. It is suitable for applications that prioritize user experience for all users.

  • react-popper-tooltip:

    react-popper-tooltip inherits accessibility features from react-popper but requires developers to ensure proper implementation for screen readers and keyboard navigation.

  • react-tippy:

    react-tippy includes some accessibility features, but developers should ensure that tooltips are accessible by following best practices for ARIA roles and attributes.

Performance

  • @popperjs/core:

    @popperjs/core is optimized for performance, ensuring that poppers are repositioned efficiently without causing layout thrashing, making it suitable for high-performance applications.

  • react-popper:

    react-popper is efficient in terms of performance, leveraging the Popper.js engine to minimize reflows and repaints during positioning updates, making it suitable for dynamic UIs.

  • react-tooltip:

    react-tooltip is lightweight and performs well for simple use cases, but performance may vary with complex tooltips or large numbers of tooltips on the page.

  • react-overlays:

    react-overlays may introduce some overhead due to its flexibility, but it is generally performant for most use cases. Developers should monitor performance in complex applications.

  • react-popper-tooltip:

    react-popper-tooltip maintains good performance by utilizing react-popper for positioning, ensuring that tooltips are rendered efficiently without significant overhead.

  • react-tippy:

    react-tippy is designed for performance, providing smooth animations and transitions while keeping the tooltip rendering lightweight, ideal for visually rich applications.

Ease of Use

  • @popperjs/core:

    @popperjs/core has a steeper learning curve due to its flexibility and low-level API, making it more suitable for experienced developers who need fine-grained control.

  • react-popper:

    react-popper is straightforward to use, providing a simple API that integrates well with React applications, making it accessible for most developers.

  • react-tooltip:

    react-tooltip is very easy to use, providing a simple API that allows developers to add tooltips with minimal setup, making it suitable for quick implementations.

  • react-overlays:

    react-overlays is relatively easy to use for developers familiar with React, but it may require additional effort to implement custom overlays effectively.

  • react-popper-tooltip:

    react-popper-tooltip is designed for ease of use, allowing developers to implement tooltips quickly without extensive configuration, making it ideal for rapid development.

  • react-tippy:

    react-tippy is user-friendly, offering a simple API and numerous examples that make it easy for developers to implement tooltips with various effects.

How to Choose: @popperjs/core vs react-popper vs react-tooltip vs react-overlays vs react-popper-tooltip vs react-tippy
  • @popperjs/core:

    Choose @popperjs/core if you need a powerful positioning engine that can be used with any framework or vanilla JavaScript. It provides precise control over the positioning of poppers and tooltips, making it ideal for complex layouts.

  • react-popper:

    Opt for react-popper if you want a React wrapper around Popper.js that simplifies the integration of poppers and tooltips into your React applications. It is great for developers who need a straightforward solution for positioning elements based on the DOM.

  • react-tooltip:

    Select react-tooltip if you need a lightweight and straightforward tooltip library that is easy to implement and customize. It is suitable for projects where simplicity and ease of use are priorities.

  • react-overlays:

    Select react-overlays if you are looking for a set of low-level components that can be used to build overlays, modals, and tooltips with a focus on accessibility and flexibility. It is suitable for developers who want to create custom overlay components.

  • react-popper-tooltip:

    Use react-popper-tooltip when you need a simple and easy-to-use tooltip component that leverages the power of react-popper. It is perfect for quick implementations where you want tooltips without extensive configuration.

  • react-tippy:

    Choose react-tippy if you want a library that provides a rich set of options for tooltips, including animations and themes. It is ideal for developers who want visually appealing tooltips with minimal setup.

README for @popperjs/core

Popper

Tooltip & Popover Positioning Engine

npm version npm downloads per month (popper.js + @popperjs/core) Rolling Versions


Positioning tooltips and popovers is difficult. Popper is here to help!

Given an element, such as a button, and a tooltip element describing it, Popper will automatically put the tooltip in the right place near the button.

It will position any UI element that "pops out" from the flow of your document and floats near a target element. The most common example is a tooltip, but it also includes popovers, drop-downs, and more. All of these can be generically described as a "popper" element.

Demo

Popper visualized

Docs

We've created a Migration Guide to help you migrate from Popper 1 to Popper 2.

To contribute to the Popper website and documentation, please visit the dedicated repository.

Why not use pure CSS?

  • Clipping and overflow issues: Pure CSS poppers will not be prevented from overflowing clipping boundaries, such as the viewport. It will get partially cut off or overflows if it's near the edge since there is no dynamic positioning logic. When using Popper, your popper will always be positioned in the right place without needing manual adjustments.
  • No flipping: CSS poppers will not flip to a different placement to fit better in view if necessary. While you can manually adjust for the main axis overflow, this feature cannot be achieved via CSS alone. Popper automatically flips the tooltip to make it fit in view as best as possible for the user.
  • No virtual positioning: CSS poppers cannot follow the mouse cursor or be used as a context menu. Popper allows you to position your tooltip relative to any coordinates you desire.
  • Slower development cycle: When pure CSS is used to position popper elements, the lack of dynamic positioning means they must be carefully placed to consider overflow on all screen sizes. In reusable component libraries, this means a developer can't just add the component anywhere on the page, because these issues need to be considered and adjusted for every time. With Popper, you can place your elements anywhere and they will be positioned correctly, without needing to consider different screen sizes, layouts, etc. This massively speeds up development time because this work is automatically offloaded to Popper.
  • Lack of extensibility: CSS poppers cannot be easily extended to fit any arbitrary use case you may need to adjust for. Popper is built with extensibility in mind.

Why Popper?

With the CSS drawbacks out of the way, we now move on to Popper in the JavaScript space itself.

Naive JavaScript tooltip implementations usually have the following problems:

  • Scrolling containers: They don't ensure the tooltip stays with the reference element while scrolling when inside any number of scrolling containers.
  • DOM context: They often require the tooltip move outside of its original DOM context because they don't handle offsetParent contexts.
  • Compatibility: Popper handles an incredible number of edge cases regarding different browsers and environments (mobile viewports, RTL, scrollbars enabled or disabled, etc.). Popper is a popular and well-maintained library, so you can be confident positioning will work for your users on any device.
  • Configurability: They often lack advanced configurability to suit any possible use case.
  • Size: They are usually relatively large in size, or require an ancient jQuery dependency.
  • Performance: They often have runtime performance issues and update the tooltip position too slowly.

Popper solves all of these key problems in an elegant, performant manner. It is a lightweight ~3 kB library that aims to provide a reliable and extensible positioning engine you can use to ensure all your popper elements are positioned in the right place.

When you start writing your own popper implementation, you'll quickly run into all of the problems mentioned above. These widgets are incredibly common in our UIs; we've done the hard work figuring this out so you don't need to spend hours fixing and handling numerous edge cases that we already ran into while building the library!

Popper is used in popular libraries like Bootstrap, Foundation, Material UI, and more. It's likely you've already used popper elements on the web positioned by Popper at some point in the past few years.

Since we write UIs using powerful abstraction libraries such as React or Angular nowadays, you'll also be glad to know Popper can fully integrate with them and be a good citizen together with your other components. Check out react-popper for the official Popper wrapper for React.

Installation

1. Package Manager

# With npm
npm i @popperjs/core

# With Yarn
yarn add @popperjs/core

2. CDN

<!-- Development version -->
<script src="https://unpkg.com/@popperjs/core@2/dist/umd/popper.js"></script>

<!-- Production version -->
<script src="https://unpkg.com/@popperjs/core@2"></script>

3. Direct Download?

Managing dependencies by "directly downloading" them and placing them into your source code is not recommended for a variety of reasons, including missing out on feat/fix updates easily. Please use a versioning management system like a CDN or npm/Yarn.

Usage

The most straightforward way to get started is to import Popper from the unpkg CDN, which includes all of its features. You can call the Popper.createPopper constructor to create new popper instances.

Here is a complete example:

<!DOCTYPE html>
<title>Popper example</title>

<style>
  #tooltip {
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 13px;
  }
</style>

<button id="button" aria-describedby="tooltip">I'm a button</button>
<div id="tooltip" role="tooltip">I'm a tooltip</div>

<script src="https://unpkg.com/@popperjs/core@^2.0.0"></script>
<script>
  const button = document.querySelector('#button');
  const tooltip = document.querySelector('#tooltip');

  // Pass the button, the tooltip, and some options, and Popper will do the
  // magic positioning for you:
  Popper.createPopper(button, tooltip, {
    placement: 'right',
  });
</script>

Visit the tutorial for an example of how to build your own tooltip from scratch using Popper.

Module bundlers

You can import the createPopper constructor from the fully-featured file:

import { createPopper } from '@popperjs/core';

const button = document.querySelector('#button');
const tooltip = document.querySelector('#tooltip');

// Pass the button, the tooltip, and some options, and Popper will do the
// magic positioning for you:
createPopper(button, tooltip, {
  placement: 'right',
});

All the modifiers listed in the docs menu will be enabled and "just work", so you don't need to think about setting Popper up. The size of Popper including all of its features is about 5 kB minzipped, but it may grow a bit in the future.

Popper Lite (tree-shaking)

If bundle size is important, you'll want to take advantage of tree-shaking. The library is built in a modular way to allow to import only the parts you really need.

import { createPopperLite as createPopper } from '@popperjs/core';

The Lite version includes the most necessary modifiers that will compute the offsets of the popper, compute and add the positioning styles, and add event listeners. This is close in bundle size to pure CSS tooltip libraries, and behaves somewhat similarly.

However, this does not include the features that makes Popper truly useful.

The two most useful modifiers not included in Lite are preventOverflow and flip:

import {
  createPopperLite as createPopper,
  preventOverflow,
  flip,
} from '@popperjs/core';

const button = document.querySelector('#button');
const tooltip = document.querySelector('#tooltip');

createPopper(button, tooltip, {
  modifiers: [preventOverflow, flip],
});

As you make more poppers, you may be finding yourself needing other modifiers provided by the library.

See tree-shaking for more information.

Distribution targets

Popper is distributed in 3 different versions, in 3 different file formats.

The 3 file formats are:

  • esm (works with import syntax — recommended)
  • umd (works with <script> tags or RequireJS)
  • cjs (works with require() syntax)

There are two different esm builds, one for bundler consumers (e.g. webpack, Rollup, etc..), which is located under /lib, and one for browsers with native support for ES Modules, under /dist/esm. The only difference within the two, is that the browser-compatible version doesn't make use of process.env.NODE_ENV to run development checks.

The 3 versions are:

  • popper: includes all the modifiers (features) in one file (default);
  • popper-lite: includes only the minimum amount of modifiers to provide the basic functionality;
  • popper-base: doesn't include any modifier, you must import them separately;

Below you can find the size of each version, minified and compressed with the Brotli compression algorithm:

Hacking the library

If you want to play with the library, implement new features, fix a bug you found, or simply experiment with it, this section is for you!

First of all, make sure to have Yarn installed.

Install the development dependencies:

yarn install

And run the development environment:

yarn dev

Then, simply open one the development server web page:

# macOS and Linux
open localhost:5000

# Windows
start localhost:5000

From there, you can open any of the examples (.html files) to fiddle with them.

Now any change you will made to the source code, will be automatically compiled, you just need to refresh the page.

If the page is not working properly, try to go in "Developer Tools > Application > Clear storage" and click on "Clear site data".
To run the examples you need a browser with JavaScript modules via script tag support.

Test Suite

Popper is currently tested with unit tests, and functional tests. Both of them are run by Jest.

Unit Tests

The unit tests use JSDOM to provide a primitive document object API, they are used to ensure the utility functions behave as expected in isolation.

Functional Tests

The functional tests run with Puppeteer, to take advantage of a complete browser environment. They are currently running on Chromium, and Firefox.

You can run them with yarn test:functional. Set the PUPPETEER_BROWSER environment variable to firefox to run them on the Mozilla browser.

The assertions are written in form of image snapshots, so that it's easy to assert for the correct Popper behavior without having to write a lot of offsets comparisons manually.

You can mark a *.test.js file to run in the Puppeteer environment by prepending a @jest-environment puppeteer JSDoc comment to the interested file.

Here's an example of a basic functional test:

/**
 * @jest-environment puppeteer
 * @flow
 */
import { screenshot } from '../utils/puppeteer.js';

it('should position the popper on the right', async () => {
  const page = await browser.newPage();
  await page.goto(`${TEST_URL}/basic.html`);

  expect(await screenshot(page)).toMatchImageSnapshot();
});

You can find the complete jest-puppeteer documentation here, and the jest-image-snapshot documentation here.

License

MIT