Blog

Mar 30, 2026

Pretext Does What CSS Can't — Measuring Text Before the DOM Even Exists

Pretext is a new JS/TS library from Cheng Lou (React core, react-motion, Midjourney) that calculates multiline text height without DOM reflow. It splits work into a one-time prepare() pass via off-screen canvas, then a pure-arithmetic layout() hot path that runs in ~0.09ms. The result: accurate pre-render height prediction for virtualized lists, chat UIs, and canvas renderers — plus layout primitives CSS literally doesn't have, like finding the minimum width for a block of text at a fixed line count. Solid i18n, rigorous accuracy testing, 7k+ GitHub stars in days. Still early: no SSR, system-ui is broken on macOS, and the 500x benchmark is the author's own caveat.

Source: HackerNoon →


Share

BTCBTC
$81,040.00
0.21%
ETHETH
$2,301.90
0.38%
USDTUSDT
$1.000
0.01%
BNBBNB
$677.47
2.32%
XRPXRP
$1.46
0.67%
USDCUSDC
$0.999
0.09%
SOLSOL
$95.19
1.71%
TRXTRX
$0.350
0.19%
FIGR_HELOCFIGR_HELOC
$1.04
0.75%
DOGEDOGE
$0.112
0.98%
WBTWBT
$59.54
0.27%
USDSUSDS
$1.000
0.01%
ADAADA
$0.274
1.51%
HYPEHYPE
$40.17
2.69%
ZECZEC
$558.68
0.57%
LEOLEO
$10.00
2.26%
BCHBCH
$443.92
0.69%
XMRXMR
$413.17
0.55%
LINKLINK
$10.47
0.17%
TONTON
$2.26
7.35%