Skip to content
chenglou/pretext website preview

chenglou/pretext

github.com

A pure JavaScript/TypeScript library for fast, accurate multiline text measurement and layout — no DOM reflow required.

What is chenglou/pretext?

Pretext, created by Cheng Lou, implements its own text measurement logic using the browsers' own font engine as ground truth, sidestepping expensive layout-triggering DOM measurements like getBoundingClientRect. It supports all the languages you didn't even know about and renders measured text to DOM, Canvas, and SVG. Install via npm as @chenglou/pretext, with exemplary demo patterns in the repo.

Best for

  • Text-heavy UIs that need measuring without layout reflow
  • Rendering measured text to DOM, Canvas, or SVG
  • Multiline layout across all the languages browsers support

Key features

  • Pure JS/TS text measurement and layout engine
  • Skips getBoundingClientRect-style layout reflow
  • Renders to DOM, Canvas, and SVG
  • Uses the browser's font engine as ground truth
  • Accurate multiline measurement across many languages
Interior.dev website preview

Free, open-source React micro-interaction components for the half-second after a click — copy the TypeScript source; the behavior is finished, the style is yours.

ReactAnimationOpen Source+2
Animal Island UI website preview

A cozy React + TypeScript component library with an original island-style design language, where every visual, icon and animation is crafted from scratch.

ReactOpen SourceIllustration+1
guokaigdg.github.io
Visitopens in a new tab
Base Ui website preview

Unstyled React UI components for building accessible web apps and design systems, from the creators of Radix, Floating UI, and Material UI.

ReactDesign SystemsOpen Source+1