External Probe / Text Layout Engine
Pretext Field Lab
This is a small observatory for Pretext.js: one prepared text handle, several widths, and a live view of how lines reflow without touching DOM measurement APIs.
import { prepare, layout } from '@chenglou/pretext'
const prepared = prepare(
'Hello, pretext.js — no reflow needed.',
'16px system-ui'
)
const { height, lineCount } = layout(prepared, 400, 24)
The lab below uses the line-producing path so the resulting wraps can be rendered directly into visible surfaces. The essential idea stays the same: prepare once, reuse the handle as widths change.
Line Break Observatory
Edit the text, change the width, and watch the same prepared handle fan out across phone, tablet, and poster surfaces.
Loading Pretext.js and waiting for fonts…
Probe Telemetry
- Prepare phase runs when text or whitespace mode changes.
- Layout phase reruns as widths change.
- Rendering shows the actual lines returned by the library.
Why Explore It
Chat and stream surfaces
Predict bubble heights before text lands so scrolling and anchoring feel intentional instead of reactive.
Virtualized knowledge lists
Estimate paragraph heights without creating hidden DOM mirrors for every item in the list.
Multilingual interfaces
Use the same API for Latin, CJK, Arabic, Hebrew, Korean, and mixed-script surfaces.
Responsive probes
Prepare once, then ask what the same text would do at phone, tablet, or desktop widths.
This page keeps the demo close to the software surface of the site, while the official playground remains the best place for exhaustive API exploration.