Home (original) (raw)
The future of Popper is here! Floating UI is now available. Get it now!
Tooltip & Popover
Positioning Engine
Weighs just 3 kB!
npm i @popperjs/core
CDN
https://unpkg.com/@popperjs/core@2
Don't mind tech-related ads? Consider disabling your ad-blocker to help us!
They are small and unobtrusive.
Alternatively, support us on Open Collective!
Placement
Click on the dots to place the tooltip. There are 12 different placements to choose from.
import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip, {
placement: 'top',
});
Popcorn
sizes
& Price
XXS: $1.99
XS: $2.99
S: $3.99
M: $4.99
L: $5.99
XL: $6.99
XXL: $7.99
Overflow prevention
Scroll the container (or the whole page) to see the tooltip stay within the boundary. Once the opposite edges of the popcorn and tooltip are aligned, the tooltip is allowed to overflow to prevent detachment.
import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip, {
placement: 'right',
});
Flipping
Scroll the container (or the whole page) to see the tooltip flip to the opposite side once it's about to overflow the visible area. Once enough space is detected on its preferred side, it will flip back.
import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip);
In a nutshell, Popper:
- Places your tooltip or popover relative to the reference taking into account their sizes, and positions its arrow centered to the reference.
- Takes into account the many different contexts it can live in relative to the reference (different offsetParents, different or nested scrolling containers).
- Keeps your tooltip or popover in view as best as possible. It prevents it from being clipped or cut off (overflow prevention) and changes the placement if the original does not fit (flipping).
Our Sponsors
Popper is proudly sponsored by the following organizations,
join them on Open Collective to support us.
Granular configuration with sensible defaults
Popper aims to "just work" without you needing to configure much. Of course, there are cases where you need to configure Popper beyond its defaults – in these cases, Popper shines by offering high granularity of configuration to fine-tune the position or behavior of your popper.
You can extend Popper with your own modifiers (or plugins) to make your popper work for you, no matter how advanced the scenario.
No compromises
- No detachment. Position updates take less than a millisecond on average devices. Popper doesn't debounce the positioning updates of the tooltip to the point where it will ever detach from its reference, but this doesn't come at the cost of poor performance.
- You don't have to change the DOM context of your tooltip or popover element; it will work no matter where your popper and reference elements live, even in the most complex scenarios like nested scrolling containers or alternative offsetParent contexts.
- Still lightweight. Handling all of this complexity is still done in an efficient manner. The base Popper is only 2 kB minzipped.