Popper

Anchored positioning helpers for overlay content.

Experimental / feature-limited
@lattice-ui/popper

early positioning foundation

What It Is For

Use popper when you need low-level anchored positioning without adopting a higher-level overlay component.

It provides the geometry engine used by packages like Select, Popover, and Tooltip.

TSX Example Preview

Preview the first lines below, or expand to inspect the full source file.

popper.tsx
TSX Preview
import { computePopper } from "@lattice-ui/popper";

export function PopperExample() {
	const result = computePopper({
		anchorPosition: new Vector2(180, 60),
		anchorSize: new Vector2(160, 40),
...

Install

Global CLI command: lattice add popper

Monorepo local script

Use your package manager wrapper when running the local lattice command.

pnpm lattice add popper

npm package: @lattice-ui/popper

Peer dependencies

  • @rbxts/react
  • @rbxts/react-roblox

Public Exports

  • computePopper
  • usePopper

State Model

  • There is no shared React context; usePopper derives position directly from anchorRef, contentRef, and geometric inputs.
  • placement, offset, and padding are the core variables that influence the computed result.
  • The returned model is just position, anchorPoint, and the resolved placement plus an update() function.

Key API

usePopper

Use anchorRef, contentRef, placement, offset, padding, and enabled for live anchored positioning in a component tree.

computePopper

Use the pure compute helper when you need the same geometry logic outside a hook-driven surface.

PopperPlacement

Current placement options are top, bottom, left, and right.

Composition Patterns

Custom anchored overlays

Pair usePopper with Portal or your own mount strategy when you want positioning but not the rest of a compound overlay package.

Measured content surfaces

Use the update() function when geometry needs to be recomputed after layout or content changes.

Cautions / Limits

  • Popper solves positioning only; it does not manage dismissal, focus, portals, or presence.
  • If anchored content animates, keep motion on an isolated wrapper so placement measurement remains authoritative.
  • The public placement model is intentionally small, so build more complex policies above it rather than expecting full menu-like behavior from the package alone.