androidx.compose.foundation.layout
Spacer
Composable function · from org.jetbrains.compose.foundation:foundation-layout:1.12.2
A Spacer is empty space. It draws nothing; it only takes up the size you give it with a modifier.
Column {
Text("Title")
Spacer(Modifier.height(16.dp))
Text("Body")
}
Push the next children to the end of a Row with a weight:
Row {
Text("Total")
Spacer(Modifier.weight(1f)) // takes all free space
Text("12.50 €")
}
For the same space between all children, Arrangement.spacedBy(8.dp) on the Row or Column is simpler than a Spacer between each.
Parameters
@Composable
fun Spacer(modifier: Modifier)
modifier: ModifierRequired
modifier: ModifierRequiredThe size of the space: Modifier.height(16.dp), Modifier.width(8.dp) or Modifier.weight(1f). Without a size, the spacer is empty and takes no space.