New Compose Multiplatform components arrived on Composables UICheck it out →

Spacer

Component that represents an empty space layout, whose size can be defined using [Modifier.width], [Modifier.height] and [Modifier.size] modifiers.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.foundation:foundation-layout:1.7.0-beta03")
}

Overloads

@NonRestartableComposable
@Composable
fun Spacer(modifier: Modifier)

Parameters

namedescription
modifiermodifiers to set to this spacer

Code Example

SpacerExample

@Composable
@Sampled
fun SpacerExample() {
    Row {
        Box(Modifier.size(100.dp).background(Color.Red))
        Spacer(Modifier.width(20.dp))
        Box(Modifier.size(100.dp).background(Color.Magenta))
        Spacer(Modifier.weight(1f))
        Box(Modifier.size(100.dp).background(Color.Black))
    }
}