skillfed

stretchable

Layout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)

stretchable v1.1.8 106.2K downloads/30d#12,661 on PyPI41
Permissive license AGING released

What it is and what it does

stretchable is a Python binding to Taffy, a Rust implementation of CSS layout algorithms (Block, Flexbox, and Grid). It lets you build a tree of layout nodes, assign CSS-like properties (margin, padding, size, flex rules), and compute final positions and dimensions—all without a browser or DOM. The library is context-agnostic, so it works equally well for UI frameworks, report generators, plotting systems, or any application needing deterministic layout math.

The package ships as pre-compiled wheels for modern Python versions (3.8–3.13) across Windows, macOS (Intel and ARM), and Linux (glibc and musl). It has one runtime dependency (attrs) and is typed. Development is steady but aging; the last release was 289 days ago, and the repository shows no signs of abandonment but also no rapid iteration.

Use it for:

  • Build responsive UI layouts for terminal applications or custom frameworks without HTML/CSS parsing.
  • Generate page layouts for PDF reports or complex data visualizations where CSS-like rules simplify positioning.
  • Compute plot layouts for multi-panel scientific figures with automatic spacing and alignment.
  • Prototype layout logic in Python before porting to web or native frontends that use the same CSS spec.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

stretchable is a Python layout engine that implements CSS Block, Flexbox, and CSS Grid layout algorithms, enabling programmatic UI and report layouts without browser dependencies.

Yes, if you need deterministic CSS-like layout computation in Python. The library is stable (Production/Stable classifier), well-typed, permissively licensed, and covers common platforms. Install friction is moderate due to compiled bindings, but wheels are pre-built. Maintenance is aging (289 days since last release) but not stalled; verify that the API and test coverage meet your edge-case needs before committing to a critical path.

Install

stretchable on PyPI

pip

pip install stretchable

uv

uv add stretchable

poetry

poetry add stretchable

Installing stretchable

Before you install

Medium install friction due to compiled Rust bindings, but pre-built wheels cover common platforms (x86_64, ARM, Windows, macOS, Linux). Last release 289 days ago; repository active with no archived status, though maintenance pace is aging.

License in practice

MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

from stretchable import Node
from stretchable.style import AUTO, PCT

root = Node(margin=20, size=(500, 300)).add(
    Node(border=5, size=(50 * PCT, AUTO)),
    Node(key="child", padding=10 * PCT, size=50 * PCT),
)
root.compute_layout()
child_node = root.find("/child")
print(child_node.get_box())

Verify before relying

  • Whether the ~900 test suite (including Selenium-based tests) reflects real-world layout accuracy across edge cases.
  • Performance characteristics when laying out very large node trees or deeply nested structures.
  • Stability and API surface coverage compared to the original Stretch library it replaced.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — attrs
Maintenance aging — 289 days since the last release
Last repo commit
First released
Downloads 106,235/month — #12,661 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl; stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl; stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl; stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl; stretchable-1.1.8-cp38-abi3-win32.whl; stretchable-1.1.8-cp38-abi3-win_amd64.whl; stretchable-1.1.8-cp38-abi3-win_arm64.whl

Keywords: flexbox, grid, block, stretch, css, layout

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyProgramming Language :: RustTyping :: Typed

Tags

css layout engine pythonflexbox grid layout librarypython layout computationcss block layout algorithmtaffy rust layout bindings
layout-enginecss-algorithmsrust-bindings

More Application Frameworks packages