Skip to content

v0.1.0 – Pretext-powered 2D Layout Engine (Pure TS, No DOM, No WASM)

Choose a tag to compare

@BaselAshraf81 BaselAshraf81 released this 30 Mar 02:37
· 38 commits to main since this release

🎉 LayoutSans v0.1.0 is here!

The missing layer after Pretext.

Pretext gives you perfect text measurement without DOM reflows.
LayoutSans takes those measurements and gives you full 2D layout: Flex, basic Grid, Magazine-style multi-column, Absolute positioning — all in pure TypeScript.

  • Zero DOM — never touches getBoundingClientRect or the browser layout engine
  • Zero WASM bloat — ~3.7 kB gzipped (core)
  • Universal — runs in Browser, Node, Bun, Deno, Cloudflare Workers, Edge
  • Pretext integration — accurate text measurement via peer dependency
  • Virtualization-ready — flat output perfect for 100k+ variable-height items at 120 fps

Highlights

  • Full Flexbox support (row/column, gap, justify, align, wrap, flex-grow/shrink)
  • Basic Grid & Magazine multi-column text flow
  • Absolute positioning
  • Text nodes powered by @chenglou/pretext
  • Clean 5-line API with .compute() returning positioned boxes
  • Benchmarks included (10k–100k boxes)

5-line demo

import { createLayout } from 'layout-sans'

const engine = createLayout({
  type: 'flex',
  direction: 'row',
  width: 800,
  gap: 16,
  children: [
    { type: 'box', flex: 1 },
    { type: 'box', width: 240 }
  ]
})

const boxes = engine.compute()