Registry / web-framework / stretchable

stretchable

JSON →
library1.1.8pypypi✓ verified 79d ago

A Python layout library that uses Taffy, a Rust-powered implementation of CSS Grid and Flexbox, to compute layouts declaratively. Current version is 1.1.8, supporting Python >=3.8. Release cadence is irregular, approximately bi-monthly.

pip install stretchable
INSTALL
IMPORT
SIG · STRETCHABLE
S
stretchable
web-frameworkpythonv1.1.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Box
from stretchable import Box
from stretchable import Auto
Node
from stretchable import Node
Style
from stretchable import Style

Quickstart: create nodes, add children, compute layout, and access results.

from stretchable import Node, LayoutTree, Style # Create a root node with flexbox layout root = Node(style=Style(size={"width": 100, "height": 100}, display="flex", flex_direction="column", gap=10)) child1 = Node(style=Style(size={"width": 50, "height": 30})) child2 = Node(style=Style(size={"width": 50, "height": 30})) # Build and compute layout tree = LayoutTree(root) root.add_child(child1) root.add_child(child2) tree.compute_layout() # Print layout of child1 layout = tree.get_layout(child1) print(f"Child1: left={layout.left}, top={layout.top}, width={layout.width}, height={layout.height}")
Debug
Known issues
gotchaNodes must be added as children before calling tree.compute_layout(), otherwise they are not part of the layout calculation.
fix
Call root.add_child(child) before tree.compute_layout().
affects: all
breakingUpgrade to v1.1.0 introduced breaking changes due to Taffy 0.5.1 upgrade. CSS Block layout and overflow support were added; some APIs changed (e.g., measure function signatures).
fix
Refer to migration notes in GitHub releases. For custom measure functions, ensure they match the new signature (width, height, available_width, available_height).
affects: >=1.1.0
gotchaThe size property in Style expects a dictionary, not a tuple. Common mistake: using size=(100, 50) instead of size={"width": 100, "height": 50}.
fix
Use dictionary format: size={'width': 100, 'height': 50}.
affects: all
deprecatedDirect assignment to Node.style (e.g., node.style = new_style) is deprecated after v1.1.1. Use setter method or property assignment carefully.
fix
Use node.style_setter() or modify individual properties of node.style (e.g., node.style.flex_direction = 'row').
affects: >=1.1.1
Upgrade
Version history
1.1.8latest on PyPI · released Oct 29, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Resources
stretchable — pip install stretchable · libregistry