https://github.com/dioxuslabs/taffy
A high performance rust-powered UI layout library
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 68 committers (1.5%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A high performance rust-powered UI layout library
Basic Info
- Host: GitHub
- Owner: DioxusLabs
- License: other
- Language: Rust
- Default Branch: main
- Homepage: https://docs.rs/taffy
- Size: 55.7 MB
Statistics
- Stars: 2,668
- Watchers: 25
- Forks: 146
- Open Issues: 91
- Releases: 48
Topics
Metadata Files
README.md
Taffy
Taffy is a flexible, high-performance, cross-platform UI layout library written in Rust.
It currently implements the CSS Block, Flexbox and CSS Grid layout algorithms. Support for other paradigms is planned. For more information on this and other future development plans see the roadmap issue.
This crate is a collaborative, cross-team project, and is designed to be used as a dependency for other UI and GUI libraries. Right now, it powers:
- Servo: an alternative web browser
- Blitz: a radically modular web engine
- Bevy: an ergonomic, ECS-first Rust game engine
- iocraft: crafting beautiful interfaces for the terminal
- The Lapce text editor via the Floem UI framework
- The Zed text editor via the GPUI UI framework
Usage
```rust use taffy::prelude::*;
// First create an instance of TaffyTree let mut tree : TaffyTree<()> = TaffyTree::new();
// Create a tree of nodes using TaffyTree.new_leaf and TaffyTree.new_with_children.
// These functions both return a node id which can be used to refer to that node
// The Style struct is used to specify styling information
let headernode = tree
.newleaf(
Style {
size: Size { width: length(800.0), height: length(100.0) },
..Default::default()
},
).unwrap();
let bodynode = tree .newleaf( Style { size: Size { width: length(800.0), height: auto() }, flex_grow: 1.0, ..Default::default() }, ).unwrap();
let rootnode = tree .newwithchildren( Style { flexdirection: FlexDirection::Column, size: Size { width: length(800.0), height: length(600.0) }, ..Default::default() }, &[headernode, bodynode], ) .unwrap();
// Call computelayout on the root of your tree to run the layout algorithm tree.computelayout(rootnode, Size::MAXCONTENT).unwrap();
// Inspect the computed layout using TaffyTree.layout
asserteq!(tree.layout(rootnode).unwrap().size.width, 800.0);
asserteq!(tree.layout(rootnode).unwrap().size.height, 600.0);
asserteq!(tree.layout(headernode).unwrap().size.width, 800.0);
asserteq!(tree.layout(headernode).unwrap().size.height, 100.0);
asserteq!(tree.layout(bodynode).unwrap().size.width, 800.0);
asserteq!(tree.layout(bodynode).unwrap().size.height, 500.0); // This value was not set explicitly, but was computed by Taffy
```
Bindings to other languages
- Python via stretchable
- WIP C bindings
- WIP WASM bindings
Learning Resources
Taffy implements the Flexbox and CSS Grid specifications faithfully, so documentation designed for the web should translate cleanly to Taffy's implementation. For reference documentation on individual style properties we recommend the MDN documentation (for example this page on the width property). Such pages can usually be found by searching for "MDN property-name" using a search engine.
If you are interested in guide-level documentation on CSS layout, then we recommend the following resources:
Flexbox
- Flexbox Froggy. This is an interactive tutorial/game that allows you to learn the essential parts of Flexbox in a fun engaging way.
- A Complete Guide To Flexbox by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different Flexbox properties and how they work.
CSS Grid
- CSS Grid Garden. This is an interactive tutorial/game that allows you to learn the essential parts of CSS Grid in a fun engaging way.
- A Complete Guide To CSS Grid by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different CSS Grid properties and how they work.
Benchmarks (vs. Yoga)
- Run on a 2021 MacBook Pro with M1 Pro processor using criterion
- The benchmarks measure layout computation only. They do not measure tree creation.
- Yoga benchmarks were run via the yoga crate (Rust bindings)
- Most popular websites seem to have between 3,000 and 10,000 nodes (although they also require text layout, which neither yoga nor taffy implement).
Note that the table below contains multiple different units (milliseconds vs. microseconds)
| Benchmark | Node Count | Depth | Yoga (ba27f9d) | Taffy (71027a8) | | --- | --- | --- | --- | --- | | yoga 'huge nested' | 1,000 | 3 | 364.60 µs | 329.04 µs | | yoga 'huge nested' | 10,000 | 4 | 4.1988 ms | 4.3486 ms | | yoga 'huge nested' | 100,000 | 5 | 45.804 ms | 38.559 ms | | big trees (wide) | 1,000 | 1 | 737.77 µs | 505.99 µs | | big trees (wide) | 10,000 | 1 | 7.1007 ms | 8.3395 ms | | big trees (wide) | 100,000 | 1 | 135.78 ms | 247.42 ms | | big trees (deep) | 4,000 | 12 | 2.2333 ms | 1.7400 ms | | big trees (deep) | 10,000 | 14 | 5.9477 ms | 4.4445 ms | | big trees (deep) | 100,000 | 17 | 76.755 ms | 63.778 ms | | super deep | 1,000 | 1,000 | 555.32 µs | 472.85 µs |
Contributions
Contributions welcome:
if you'd like to use, improve or build taffy, feel free to join the conversation, open an issue or submit a PR.
If you have questions about how to use taffy, open a discussion so we can answer your questions in a way that others can find.
Owner
- Name: Dioxus Labs
- Login: DioxusLabs
- Kind: organization
- Website: https://dioxuslabs.com
- Twitter: dioxuslabs
- Repositories: 26
- Profile: https://github.com/DioxusLabs
Fullstack app framework for web, desktop, and mobile.
GitHub Events
Total
- Create event: 30
- Release event: 13
- Issues event: 41
- Watch event: 495
- Delete event: 16
- Issue comment event: 94
- Push event: 140
- Pull request review comment event: 20
- Pull request review event: 43
- Pull request event: 192
- Fork event: 31
Last Year
- Create event: 30
- Release event: 13
- Issues event: 41
- Watch event: 495
- Delete event: 16
- Issue comment event: 94
- Push event: 140
- Pull request review comment event: 20
- Pull request review event: 43
- Pull request event: 192
- Fork event: 31
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Nico Burns | n****o@n****m | 313 |
| Emil Sjölander | e****l@v****p | 246 |
| Alice Cecile | a****e@g****m | 38 |
| dependabot[bot] | 4****] | 36 |
| Andreas Weibye | 1****e | 30 |
| msiglreith | m****h@g****m | 19 |
| David Flemström | d****m@g****m | 17 |
| Yurii Nakonechnyi | i****r@g****m | 15 |
| TimJentzsch | t****h@g****e | 13 |
| Adam Nemecek | a****k@g****m | 12 |
| elbaro | e****o | 9 |
| Jonathan Kelley | j****p@g****m | 6 |
| adjabaev | a****3@g****m | 5 |
| François | m****f@g****m | 5 |
| ickshonpe | d****s@g****m | 4 |
| Josh McKinney | j****a | 4 |
| Marcello Vaz | 7****z | 3 |
| Dusty DeWeese | d****e@g****m | 3 |
| George Atkinson | g****s@y****k | 3 |
| Marcin Jaworski | m****n@j****e | 3 |
| Steve Heron | s****e@h****m | 3 |
| Steven Novaryo | 6****o | 2 |
| Simon Sapin | s****n@e****g | 2 |
| Pēteris Pakalns | p****s@g****m | 2 |
| Noah Gilmore | n****e@g****m | 2 |
| Mike Pennisi | m****e@m****m | 2 |
| Erik Sandrén | e****n@s****o | 2 |
| Emil Sjölander | s****l@g****m | 2 |
| Conall Keane | k****l@p****e | 2 |
| Adam Perry | a****y@g****m | 2 |
| and 38 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 136
- Total pull requests: 470
- Average time to close issues: 4 months
- Average time to close pull requests: 14 days
- Total issue authors: 67
- Total pull request authors: 40
- Average comments per issue: 2.24
- Average comments per pull request: 0.85
- Merged pull requests: 381
- Bot issues: 0
- Bot pull requests: 68
Past Year
- Issues: 32
- Pull requests: 178
- Average time to close issues: about 1 month
- Average time to close pull requests: 3 days
- Issue authors: 21
- Pull request authors: 15
- Average comments per issue: 0.47
- Average comments per pull request: 0.25
- Merged pull requests: 146
- Bot issues: 0
- Bot pull requests: 36
Top Authors
Issue Authors
- nicoburns (39)
- alice-i-cecile (11)
- PPakalns (5)
- Weibye (5)
- TimJentzsch (4)
- BrandonDyer-Disney (3)
- vkurchatkin-miro (3)
- ickshonpe (2)
- mxsdev (2)
- jrmoulton (2)
- mockersf (2)
- ammarahm-ed (2)
- SimonSapin (2)
- giannissc (2)
- viridia (2)
Pull Request Authors
- nicoburns (309)
- dependabot[bot] (70)
- inobelar (16)
- joshka (8)
- Weibye (6)
- SimonSapin (5)
- kokoISnoTarget (4)
- TimJentzsch (4)
- julia-script (4)
- PPakalns (4)
- stevennovaryo (4)
- TtTRz (4)
- tistatos (4)
- ickshonpe (3)
- andreiltd (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- cargo 3,351,064 total
- Total docker downloads: 18,669,296
-
Total dependent packages: 13
(may contain duplicates) -
Total dependent repositories: 989
(may contain duplicates) - Total versions: 147
- Total maintainers: 3
crates.io: taffy
A flexible UI layout library
- Documentation: https://docs.rs/taffy/
- License: MIT
-
Latest release: 0.9.1
published 6 months ago
Rankings
Maintainers (3)
proxy.golang.org: github.com/DioxusLabs/taffy
- Documentation: https://pkg.go.dev/github.com/DioxusLabs/taffy#section-documentation
- License: other
-
Latest release: v0.9.0
published 7 months ago
Rankings
proxy.golang.org: github.com/dioxuslabs/taffy
- Documentation: https://pkg.go.dev/github.com/dioxuslabs/taffy#section-documentation
- License: other
-
Latest release: v0.9.0
published 7 months ago
Rankings
Dependencies
- actions-rs/cargo v1 composite
- actions-rs/toolchain v1 composite
- actions/checkout v3 composite
- docker://ghcr.io/github/super-linter slim-v4 composite
- actions-rs/toolchain v1 composite
- actions/checkout v3 composite
- criterion 0.4 development
- rand 0.8.5 development
- rand_chacha 0.3.1 development
- rstest 0.16.0 development
- arrayvec 0.7
- grid 0.9.0
- num-traits 0.2
- rand 0.8.5
- serde 1.0
- slotmap 1.0.6