logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·31.10.26
← Back to news

Taffy: A flexible, high-performance, cross-platform UI layout library

Original article
github.com|72 points|27 comments|by robin_reala|Aug 13, 2026

Taffy: A flexible, high-performance, cross-platform UI layout library

GitHub CI crates.io docs.rs Crates.io MSRV

Taffy is a high-performance layout engine developed in Rust, designed to be cross-platform and highly adaptable. It serves as a foundational dependency for other GUI and UI frameworks rather than a standalone UI toolkit.

🛠 Core Capabilities

Taffy currently provides faithful implementations of the following layout algorithms:

  • CSS Block
  • Flexbox
  • CSS Grid

[!NOTE] For a deeper dive into the project's trajectory and planned features, please consult the official roadmap issue.


🌐 Ecosystem Integration

Taffy is a collaborative effort used across various high-profile projects. The following diagram illustrates the relationship between Taffy and the engines it powers:


💻 Quick Start Guide

To integrate Taffy, you primarily interact with the TaffyTree and Style structs.

use taffy::prelude::*;

// Initialize the layout tree
let mut tree: TaffyTree = TaffyTree::new();

// Define styles and create nodes
// Nodes are created via new_leaf or new_with_children, returning a unique node ID
let header_node = tree.new_leaf(Style { 
    size: Size { width: length(800.0), height: length(100.0) }, 
    ..Default::default() 
});

let content_node = tree.new_leaf(Style { 
    size: Size { width: length(800.0), height: auto() }, 
    flex_grow: 1.0, 
    ..Default::default() 
});

let root_node = tree.new_with_children(
    Style { 
        flex_direction: FlexDirection::Column, 
        size: Size { width: length(800.0), height: length(600.0) }, 
        ..Default::default() 
    }, 
    &[header_node, content_node]
).unwrap();

// Execute the layout algorithm starting from the root
tree.compute_layout(root_node, Size { width: length(800.0), height: length(600.0) }).unwrap();

// Retrieve and verify the computed dimensions
let layout = tree.layout(content_node).unwrap();
assert_eq!(layout.size.height, 500.0); // Computed automatically by Taffy

Language Support

Taffy is expanding its reach beyond Rust:

  • WASM bindings
  • Python (via stretchable) →\rightarrow→ WIP
  • C bindings →\rightarrow→ WIP

📚 Learning Resources

Since Taffy adheres strictly to web specifications, standard CSS documentation is the best way to learn its behavior.

Reference Material:

  • MDN Web Docs: Search for "MDN [property-name]" (e.g., the width property) for detailed technical specs.

Interactive Guides:

Layout TypeInteractive GameComprehensive Guide
FlexboxFlexbox FroggyDetailed Flexbox Guide
CSS GridGrid GardenDetailed Grid Guide

🚀 Performance Benchmarks

Taffy was tested against Yoga on a 2021 MacBook Pro (M1 Pro) using criterion.

Important Context:

  • Benchmarks focus solely on layout computation.
  • Text layout is implemented →\rightarrow→ Neither Taffy nor Yoga implement text layout.
  • Typical websites range from 3,0003,0003,000 to 10,00010,00010,000 nodes.

The computation time can be viewed as a function of node count NNN and tree depth DDD: Time=f(N,D)\text{Time} = f(N, D)Time=f(N,D)

BenchmarkNode CountDepthYoga (ba27f9d)Taffy (71027a8)
yoga 'huge nested'1,0003364.60 μs364.60\ \mu\text{s}364.60 μs329.04 μs329.04\ \mu\text{s}329.04 μs
yoga 'huge nested'10,00044.1988 ms4.1988\ \text{ms}4.1988 ms4.3486 ms4.3486\ \text{ms}4.3486 ms
yoga 'huge nested'100,000545.804 ms45.804\ \text{ms}45.804 ms38.559 ms38.559\ \text{ms}38.559 ms
big trees (wide)1,0001737.77 μs737.77\ \mu\text{s}737.77 μs505.99 μs505.99\ \mu\text{s}505.99 μs
big trees (wide)10,00017.1007 ms7.1007\ \text{ms}7.1007 ms8.3395 ms8.3395\ \text{ms}8.3395 ms
big trees (wide)100,0001135.78 ms135.78\ \text{ms}135.78 ms247.42 ms247.42\ \text{ms}247.42 ms
big trees (deep)4,000122.2333 ms2.2333\ \text{ms}2.2333 ms1.7400 ms1.7400\ \text{ms}1.7400 ms
big trees (deep)10,000145.9477 ms5.9477\ \text{ms}5.9477 ms4.4445 ms4.4445\ \text{ms}4.4445 ms
big trees (deep)100,0001776.755 ms76.755\ \text{ms}76.755 ms63.778 ms63.778\ \text{ms}63.778 ms
super deep1,0001,000555.32 μs555.32\ \mu\text{s}555.32 μs472.85 μs472.85\ \mu\text{s}472.85 μs

🤝 Contributing

We welcome all contributions! Whether you want to use Taffy in your project, improve the codebase, or build new features, feel free to join the conversation, open an issue, or submit a Pull Request.

Need help? If you have usage questions, please open a discussion so the answers remain searchable for the entire community.