Skip to content

bluedusk/awesome-pretext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awesome Pretext

Awesome Stars Downloads Last commit

A curated collection of demos, projects, tips, tutorials, and news for Pretext — the DOM-free text layout engine by Cheng Lou that's 500x faster than browser layout.

Try the interactive demo →

Pretext is a 15KB, zero-dependency TypeScript library that measures and positions text using Canvas with pure-arithmetic reflows. No DOM, no WASM — just math.

Last auto-updated: 2026-04-06 (via /awesome-pretext-update)

Contents


Demo Gallery

Official Pretext Demos
Official Demos

Accordion, bubbles, dynamic layout, ASCII art
Pretext Breaker
Pretext Breaker

Breakout game where bricks are made of text
Tetris x Pretext
Tetris x Pretext

Classic Tetris with Pretext-powered text layout
Illustrated Manuscript
Illustrated Manuscript

Medieval manuscript with animated dragon and live reflow
Dragon Through Text
Dragon Through Text

The viral dragon animation flowing through paragraphs
Bad Apple ASCII
Bad Apple!! ASCII

Shadow art PV as real-time ASCII animation

Demos

Games & Flagship

Demo Author Description Repo
Bad Apple!! ASCII frmlinn The legendary Bad Apple!! shadow art PV as real-time ASCII text animation GitHub
Pretext Playground 0xNyk Interactive ASCII dragon, physics-driven letters, fire breathing, 3D text tunnel GitHub
Pretext Breaker rinesh Breakout-style arcade game where bricks are made of text, with sound effects GitHub
Tetris x Pretext shinichimochizuki Classic Tetris reimagined with Pretext-powered text layout GitHub
Somnai Pretext Demos somnai-dreams Five polished demos: editorial engine, fluid smoke ASCII, justification comparison GitHub
PreText Experiments qtakmalay Eleven demos including Dragon animation, Anime Walk, Masonry layout GitHub

Visual & Interaction

Demo Author Description Repo
Pretext Explosive SamiKamal Text that shatters — explosive particle effects powered by Pretext layout GitHub
Star Wars Crawl berryboylb The iconic opening crawl recreated with perspective text animation GitHub
Singularity & Liquid Grid progrmoiz Black-hole text singularity, liquid dashboard grid, and draw-to-fill text vessels GitHub
Drag Sprite Reflow dokobot Drag a sprite across text and watch paragraphs reflow in real time GitHub
Responsive Testimonials jalada Auto-sizing testimonial quotes that adapt to container width GitHub
Alarmy Editorial Clock SmisLee Multi-column editorial layout flowing around an animated analog clock GitHub

Experiments

Demo Author Description Repo
Illustrated Manuscript dengshu2 Medieval illuminated manuscript with animated dragon and live text reflow GitHub
Text Flow Demo MaiMcdull News-style flowing text layout with a comparison shim for benchmarking GitHub
Sea of Words Mukul-svg Words flowing as ocean waves with wrap geometry in a canvas scene GitHub
World Model Test CharlieGreenman Minimal world-model interface powered by DOM-free text measurement GitHub
Face x Pretext sachinkasana TensorFlow.js face tracking drives real-time Pretext typography GitHub
DOM vs Pretext clawsuo-web Side-by-side performance comparison between DOM layout and Pretext GitHub

Emerging Demos

Demo Author Description Repo
TypeBeat Alexander Chen A drum machine entirely made of text — each character triggers a sound. Built with Pretext + Gemini. X post
Typexperiments pablostanley Kinetic typography engine — smooth per-character text animations on Canvas GitHub
BioMap Kevin Ho 52 biomarker blocks that expand and reflow text every frame — 0.04ms for all 52 layouts X post
Pretext Wars jameslcowan Space-themed game — destroy poetry with your spaceship GitHub
Pretext Slides ShipItAndPray Presentation tool rendering slides in Canvas with Pretext — write markdown, present anywhere GitHub
Pretext Lab XergioAleX Interactive playground — drag width sliders, masonry grids, chat bubbles, text flow around shapes site

Live Demos

  • Official Pretext Demos — Accordion, bubbles, dynamic layout, ASCII art from Cheng Lou.
  • Dragon Through Text — The viral dragon animation flowing through paragraphs.
  • Pretext Breaker — Playable Breakout game in the browser.
  • Pretext Lab — Interactive playground with drag-to-resize, masonry, chat bubbles, text flow around shapes.

Community Projects

High-star GitHub projects built with or extending Pretext. Star counts and activity badges are live via shields.io.

Project Stars Last Commit Description
pretext Stars Last commit The library itself — DOM-free text measurement and layout
always-fit-resume Stars Last commit Resume builder that auto-scales to always fit one page
textura Stars Last commit Pretext x Yoga — DOM-free layout engine for the web
pinch-type Stars Last commit Pinch to zoom text, not the page
swift-pretextkit Stars Last commit Swift port of Pretext for Apple platforms
layout-sans Stars Last commit Pure TypeScript 2D layout engine — Flex, Grid, Magazine — zero DOM
pretext-video Stars Last commit Webcam into living typography via Pretext + MediaPipe
pretext-playground Stars Last commit Interactive ASCII dragon playground with physics
pretext-demos Stars Last commit Five polished layout engine demos

Emerging Projects

Project Stars Last Commit Description
typexperiments Stars Last commit Kinetic typography engine — per-character animations on Canvas
nim-pretext Stars Last commit Nim WASM port of Pretext — up to 9.5x faster than JS
pretext-php Stars Last commit PHP port with ICU segmentation and injectable font measurement
pretext_dart Stars Last commit Dart/Flutter port — pure-arithmetic multiline text layout

Tutorials

Guides

Reference Docs

Latest Tutorials & Courses

  • Learn Pretext — 25+ interactive tutorials with live demos and annotated source code covering text measurement, layout, and advanced reflow techniques.
  • How to Use Pretext.js: A Practical Guide — Hands-on guide covering installation, API basics, text reflow around obstacles, multi-slot layouts, and performance benchmarks.
  • Pretext.js Tutorial — How to install and start measuring text layout in JS/TS. Published April 2, 2026.
  • Knuth-Plass Justification with Pretext — Yining Karl Li implemented TeX-quality justified text on a blog using Pretext under the hood.
  • Pretext + Three.js Guide — Combining Pretext for precision text layout with Three.js for spatial embodiment. By TachikomaRed.

No new courses found this cycle.


Articles & Blog Posts

Latest Articles


Videos & Talks

Pretext is brand new (March 2026) — video content is still emerging. Contributions welcome!

Latest Videos


Integrations

Pretext is framework-agnostic — it works identically in any JavaScript environment.

Framework Pattern
React Call prepare() in useMemo, call layout() on resize via useLayoutEffect
Vue Use computed for prepare(), watch container width for layout()
Svelte Reactive $: block for prepare(), bind container width for layout()
Angular Service-cached prepare(), ResizeObserver triggers layout()
Vanilla JS Direct usage with ResizeObserver or requestAnimationFrame
Node.js / SSR Server-side text measurement with Canvas polyfill

Framework Libraries

  • textura — Pretext x Yoga integration for full DOM-free layout (Flex, Grid, etc.)
  • swift-pretextkit — Swift port for Apple platforms (iOS, macOS)
  • layout-sans — Pure TypeScript 2D layout engine built on Pretext

Boilerplates & Starters

Pretext is still very new — starter templates are emerging. Contributions welcome!

Quick Start

git clone https://github.com/chenglou/pretext.git
cd pretext
bun install
bun start
# Open /demos in your browser

Real Apps

Production applications and real-world use cases powered by Pretext.

  • Midjourney — Pretext was born from production needs at Midjourney, where ~5 engineers serve millions of users. Streaming AI tokens triggered continuous text reflows — the bottleneck that motivated the library.
  • always-fit-resume — Resume builder that auto-scales font size and line spacing to always fit one page.
  • pinch-type — Pinch-to-zoom text experience.
  • pretext-video — Webcam-to-typography in the browser via Pretext + MediaPipe.

Real-World Use Cases

  • Virtualization — Pre-compute heights for thousands of variable-height items without DOM. Works with React Virtuoso, TanStack Virtual, etc.
  • Streaming AI responses — Predict chat bubble heights before streaming tokens finish, eliminating layout shift.
  • Text updates at scale — Size tooltips, cells, and cards without forced reflow. 60fps even with hundreds of simultaneous updates.
  • Responsive design — Compute text heights at multiple breakpoints from a single prepare() call.

Benchmarks & Performance

Numbers

Browser layout() DOM measurement Speedup
Chrome 0.09ms 43.50ms 483x
Safari 0.12ms 149.00ms 1,242x
  • prepare() is the expensive phase (~19ms for 500 text segments) — but only runs once per text+font combo
  • layout() is pure arithmetic — safe for requestAnimationFrame hot paths
  • 7680/7680 character-level accuracy across Chrome, Safari, and Firefox

Benchmark Projects

How It Works

  1. prepare() — Normalize whitespace, segment text via Intl.Segmenter for locale-aware word boundaries, handle bidi text, measure segments with off-screen Canvas, cache results.
  2. layout() — Pure calculation over cached widths. No DOM, no reflow, no paint. Just math.

News

March 2026 — Pretext Launches

March 27, 2026 — Cheng Lou released Pretext as an open-source MIT-licensed library. Within 48 hours: 14,000+ GitHub stars, 19 million views on X.

Key coverage:

Milestones

  • 35,000+ stars on GitHub (as of April 2026)
  • Built using AI-assisted development (Claude + Codex), trained for weeks on browser ground truth
  • 18+ community demos from independent developers within days of launch

People to Follow

Who Role Links
Cheng Lou Creator of Pretext. Previously React core team, ReasonML/ReScript creator, react-motion author. Currently at Midjourney. GitHub · Website
Linus Ekenstam Designer who highlighted Pretext's impact on web design Threads
Den Odell Author of "You're Looking at the Wrong Pretext Demo" DEV.to
Simon Willison Covered Pretext on his blog Blog

Community


Related Projects

Libraries and tools in the same problem space as Pretext.

Project Description
Yoga Cross-platform layout engine (Flexbox) by Meta. Textura combines it with Pretext.
opentype.js JavaScript parser and writer for OpenType fonts — complementary for font-level work.
react-motion Also by Cheng Lou — animation library for React that shares the "math over DOM" philosophy.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request to add demos, projects, tips, tutorials, articles, or news.

License

CC0 1.0 Universal

About

A curated list of demos, community projects, tips, tutorials, and news for @chenglou/pretext — the 15KB DOM-free text layout engine that's 500x faster than browser layout

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors