Skip to content
Layout

Spacer

Push siblings apart with flexible empty space

Spacer is an empty layout used to insert gaps. Given a weight inside a Row or Column it absorbs all leftover space, shoving the elements on either side to opposite ends.

Spacer demos rendered in Compose Playground
Pixel-accurate preview · light theme

Examples

01

Push apart

A weighted Spacer separates the leading and trailing text.

Kotlin
Row(modifier = Modifier.fillMaxWidth()) {
    Text("Left")
    Spacer(Modifier.weight(1f))
    Text("Right")
}