usePosition

usePosition is a positioning engine for aligning a <dialog> or <tooltip> with something else.

It is very similar to popper.

Usage

{ style, arrowStyle, placement } = usePosition(target, { anchor, arrow, placements, contain, scroll, active })

Arguments:

Returns:

Styles

The library works by setting transform: translate(x, y) on the target and arrow. It expects the target, and arrow if used, to have position: absolute. The targets margins will be taken into account when positioning.

Sample styles are provided in the styles directory.