1use taffy::prelude::*;
2
3// Creates three 20px x 20px children, evenly spaced 10px apart from each other
4// Thus the container is 80px x 20px.
5
6fn main() -> Result<(), taffy::error::TaffyError> {
7 let mut taffy = Taffy::new();
8
9 let child_style =
10 Style { size: Size { width: Dimension::Points(20.0), height: Dimension::Points(20.0) }, ..Default::default() };
11 let child0 = taffy.new_leaf(child_style)?;
12 let child1 = taffy.new_leaf(child_style)?;
13 let child2 = taffy.new_leaf(child_style)?;
14
15 let root = taffy.new_with_children(
16 Style { gap: Size { width: Dimension::Points(10.0), height: Dimension::Undefined }, ..Default::default() },
17 &[child0, child1, child2],
18 )?;
19
20 // Compute layout and print result
21 taffy.compute_layout(root, Size::MAX_CONTENT)?;
22 taffy::debug::print_tree(&taffy, root);
23
24 Ok(())
25}