Taffy Layout Documentation

High-performance, cross-platform UI layout engine.

Taffy Layout is a high-performance layout engine written in Rust and compiled to WebAssembly for JS/TS. It implements browser-grade Flexbox and Grid algorithms without a DOM, making it ideal for terminal UIs, canvas renderers, game UI, and custom rendering engines.

What You Can Build

  • DOM-free Layouts: CSS-style layouts for Canvas, WebGL, or Terminal apps.
  • Massive Trees: Handle large UI trees with fast, deterministic performance.
  • Custom Measurement: Support for text, images, and dynamic content sizing.
  • Reusable Patterns: Layout patterns that map cleanly to UI components.

Documentation Map

SectionDescription
Getting StartedInstallation, initialization, and your first layout.
Core ConceptsThe sizing model, available space, and measurement.
StylingFlexbox, Grid, Spacing, Sizing, and Positioning.
CookbookReady-to-copy layout patterns for common UIs.
AdvancedDebugging, performance optimization, and error handling.
API ReferenceDetailed API documentation (autogenerated).

Minimal Mental Model

Using Taffy involves three simple steps:

  1. Construct: Build a tree of nodes with styles.
  2. Compute: Calculate the layout based on available space.
  3. Read: Retrieve the computed x, y, width, and height.
UI Tree Structure: └── TaffyTree ├── Style (Input: Rules like Flex, Width, Padding) └── Layout (Output: Computed X, Y, Width, Height)

Next Steps

© 2026 ByteLand Technology Limited