Floating Position
Position floating content relative to a trigger element. Handles collision detection, auto-flipping to opposite sides, and viewport boundary shifting.
Installation
dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.
The hosted registry is not public yet because r.b4r7.dev does not resolve. Use this source checkout or a local registry preview until the endpoint returns 200.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.
Parameters
Returns
Examples
Basic Positioning
Notes
Collision Detection
When content would overflow the viewport, the hook tries the opposite side first, then cross-axis sides, and finally shifts the position to stay within bounds.
Layout Effect
Uses useLayoutEffect to compute position synchronously before paint, preventing visual flicker.
Late Attachment
The content callback ref participates in the positioning lifecycle, so content mounted after the overlay opens is measured immediately and receives resize and scroll subscriptions.
Used By
Built into PopoverContent for automatic positioning of popovers and tooltips.
Source
Highlighted source loads after this disclosure opens. Browse the source repository.