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
$80,910.00
0.15%
ETHETH
$2,298.99
0.1%
USDTUSDT
$1.000
0.01%
BNBBNB
$676.80
2.55%
XRPXRP
$1.46
0.21%
USDCUSDC
$0.999
0.12%
SOLSOL
$95.01
1.23%
TRXTRX
$0.350
0.16%
FIGR_HELOCFIGR_HELOC
$1.04
0.75%
DOGEDOGE
$0.112
1.65%
WBTWBT
$59.42
0.24%
USDSUSDS
$1.000
0.01%
ADAADA
$0.273
1.36%
HYPEHYPE
$40.10
2.89%
LEOLEO
$9.99
2.05%
ZECZEC
$549.42
2.06%
BCHBCH
$437.90
2.28%
LINKLINK
$10.54
0.94%
XMRXMR
$414.38
1.16%
TONTON
$2.27
8.48%