Spacer
Spacer is the invisible space-taking widget.
It solves two different layout problems. First, it can create a fixed gap by giving it a width or height. Second, it can absorb leftover space by giving it flex_grow > 0.0. That makes it especially useful inside Row and Column.
Use Spacer when empty space is a real layout participant. Do not use it for ordinary repeated sibling spacing when gap on a row or column would say the same thing more clearly.
Example
use fission::core::ui::{Row, Spacer, Text};
let node = Row {
children: vec![
Text::new("Back").into_node(),
Spacer {
flex_grow: 1.0,
..Default::default()
}
.into_node(),
Text::new("Save").into_node(),
],
..Default::default()
}
.into_node();
Field table
| Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | Option<NodeId> | Stable node identity. | Defaults to None. |
width | Option<f32> | Fixed width. | Defaults to None. |
height | Option<f32> | Fixed height. | Defaults to None. |
flex_grow | f32 | Extra space this spacer should absorb. | Defaults to 0.0. Set this above zero for push-apart behavior. |
Layout behavior
Spacer lowers to a simple box layout node with no child content. When flex_grow is zero, its effect comes only from fixed width or height. When flex_grow is positive, it behaves like a flexible spring inside the surrounding layout.
This is why Spacer is excellent for toolbars and headers where one group of controls should be pushed away from another.
Specific advice
Use gap on Row and Column for ordinary repeated spacing, and use Spacer when the empty space itself needs to flex. That distinction keeps layouts readable.