- Tiny
- Core is just under 4kb
- 0 dependencies
- Low Level
[!NOTE]
The module is ESM Only
npm i @preachjs/popper
import { createPopper } from '@preachjs/popper'
const anchor = document.getElementById('anchor')
const popover = document.getElementById('menu')
const popper = createPopper(anchor, popover)
popper.move('bottom', 'center').offset(2)
// Doesn't do anything unless `.align` is called a.k.a, a Lazy API
popper.align()
import { arrow } from '@preachjs/popper/arrow'
import { createPopper } from '@preachjs/popper'
const arrowElement = document.getElementById('arrow')
const popper = createPopper(anchor, popover)
popper.use(arrow(arrowElement))
popper.toggleArrow()
// or
// popper.toggleArrow(true) - will add a `data-popper-arrow-visible` property on the passed arrow element
// popper.toggleArrow(false)
// remaining code
popper.align()
popper
is a tiny low level vanilla javascript library built to support other
UI components that preachjs wishes to build. It doesn't have magical behaviours
and just manages semantic positioning.
Behaviours would differ based on the UI component it's being used in and will normally involve something like Preact(+Signals) that handle state
Why not use X?
Probably too large of an API surface area or overall size which I wish to avoid, at least right now.
It's missing XYZ!
Feel free to raise feature requests, do know that the scope of the library itself is pretty small. You can always write plugins to extend it's behaviour.