Skip to content

Spacer

A spacer takes all the free space along the axis of its VStack or HStack and pushes the other children apart. The stack needs a size for this to have a visible effect, e.g. through a Frame or FullWidth().

Spacer

return HStack(
	Text("Leading").BackgroundColor("#C9E7F8").Padding(Padding{}.All(L16)),
	Spacer(),
	Text("Trailing").BackgroundColor("#FDE2C4").Padding(Padding{}.All(L16)),
).BackgroundColor(ColorCardBody).
	Padding(Padding{}.All(L8)).
	Frame(Frame{Width: L560})

Constructors

ConstructorDescription
Spacer() TSpacerCreates a dynamic spacer that expands to fill available space.

Methods

MethodDescription
BackgroundColor(backgroundColor Color) TSpacerSets the background color of the spacer.
Border(border Border)Intended to set the border of the spacer, but currently has no effect, see the note below.
Frame(frame Frame) TSpacerSets the frame of the spacer, allowing control over its layout constraints.
Border neither returns the spacer nor modifies it, so it cannot be chained and has no effect.

Related