Documentation / Reference

spacer

Consume remaining space inside a row or column.

Construction

Use spacer() -> Spacer. Import constructors and common modifiers from refract::prelude::*.

spacer.rs
use refract::prelude::*;

let toolbar = h_stack()
    .alignment(Alignment::Center)
    .child(text("Library"))
    .child(spacer())
    .child(text("12 items"))
    .fill_width();

Available space

spacer creates an empty box with a grow factor of 1. Place it directly in a row or column with available space. Multiple growing children share that space according to their grow factors.

A spacer does not establish the size of its parent. Use a bounded container or fill_width/fill_height when the parent offers space.

View-specific reference

spacer returns Spacer, an empty element with shared style modifiers and no child or stack layout methods. Shared grow can change its relative growth factor. padding and frame introduce wrappers, so apply growth to the element that participates directly in the parent layout.

Common view modifiers

Dimensions, paint, labels, and disabled state preserve each concrete builder type, so their builder methods can be interleaved. padding and frame return wrappers; configure the inner element before adding those. ViewExt supplies the shared API for composed views.

See View Modifiers for shared methods and modifier ordering. Focus bindings and callbacks preserve concrete builders; see focus modifiers and Input & Focus for requests, observation, and indicators.

Source reference

The implementation is in crates/core/src/view/primitives.rs. Primitive and layout builders are in crates/core/src/view/primitives.rs. Shared modifiers are in crates/core/src/view/modifiers.rs. Style values and validation are in crates/core/src/style.rs.