MODULE · TYPESCRIPT
fitbox
Reflow-free text-to-box fitting for React, built on Pretext
★ 9
Stars
↓ 124
Per week
◇ TypeScript
Language
INSTALL
$ bun add @darkroomengineering/fitboxFeatures
Reflow-free measurement
uses canvas.measureText(), never getBoundingClientRect(), so it never thrashes layout
Closed-form single line
single-line fit is fontSize = W / w1, with no DOM search
Reflow-free multi-line
multi-line fit is a binary search to pixel precision, still pure arithmetic
Static fluid CSS
emits a clamp() so the responsive curve runs with zero runtime JS
SSR-ready
computes on a server canvas polyfill and hydrates with no layout shift
Backend-agnostic
the layout feeds WebGL/WebGPU, Canvas, SVG, or PDF, not just the DOM
Tiny
around 1.25KB core and 1.5KB for the React adapter, min+gz