stretchable
Layout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)
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 stretchableuv
uv add stretchablepoetry
poetry add stretchableInstalling 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
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
pictexPicTex generates high-quality PNG, JPEG, WebP,…
permissive · top 15,000 on PyPI
sphinx_designA Sphinx extension that adds responsive web…
permissive · top 5,000 on PyPI
minify-htmlMinifies HTML, JavaScript, and CSS in a single…
permissive · top 5,000 on PyPI
ruff-formatProvides Python bindings to Ruff's code…
permissive · top 15,000 on PyPI
sphinx-panelsA Sphinx extension that adds directives for…
permissive · top 15,000 on PyPI
dash-bootstrap-componentsProvides Bootstrap v5 components for Plotly…
permissive · top 5,000 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
grandalfGrandalf computes node coordinates and routes…
copyleft · top 5,000 on PyPI
django-crispy-formsRenders Django forms programmatically with full…
permissive · top 5,000 on PyPI
seleniumSelenium provides Python bindings to automate…
permissive · top 1,000 on PyPI