LayoutSans: Full 2D layout engine built on top of Pretext (flex, grid, magazine — zero DOM)

Published: (March 30, 2026 at 10:35 AM EDT)
1 min read
Source: Dev.to

Source: Dev.to

Overview

Pretext solves text measurement without touching the DOM.

LayoutSans builds on top of Pretext: it consumes Pretext’s measurements and provides complete flex, grid, magazine‑style multi‑column, and absolute layouts while keeping text nodes in the real DOM.

This approach delivers:

  • Accurate variable‑height virtualization
  • Dynamic layouts and complex flows without layout thrashing
  • Full accessibility, text selection, and find‑in‑page support

Features

  • Pure TypeScript library (~3.7 kB gzipped)
  • Works in browsers, Node, Bun, Deno, and Cloudflare Workers
  • Flat output format, ideal for virtual lists and canvas‑backed UIs
  • Requires Pretext as a peer dependency for handling text nodes

Getting Started

A 5‑line example and performance benchmarks are available in the repository’s README.

Call for Feedback

Feedback is welcome from anyone building virtualized UIs, chat interfaces, or editorial tools.

0 views
Back to Blog

Related posts

Read more »

A neccessary review

In our first class I was behind the ball in the first 5 minutes. Even remembering how to start up my test server was a distant memory from App Dev I. Throughout...