Skip to main content

Module spacer

Module spacer 

Source
Expand description

Spacer — an invisible, flexible gap that claims all available space on the container’s main axis.

Place a Spacer inside an HStack or VStack to push adjacent siblings to opposite edges; flank a child with two spacers to centre it. A spacer carries flex weight 1.0 and zero wanted size, so it soaks up leftover slack without imposing a cross-axis floor. min_length sets a hard minimum so the gap never collapses below a fixed amount under tight layout.

// Title hugs the leading edge, badge is pushed to the trailing edge.
let _row = HStack::new()
    .child(TextWidget::new(lit!("Title")))
    .child(Spacer::new())
    .child(TextWidget::new(lit!("NEW")));

Structs§

Spacer
An invisible, flexible gap that claims a container’s leftover main-axis space.