androidx.compose.foundation.layout

Row

Composable function · from org.jetbrains.compose.foundation:foundation-layout:1.12.2

Row places its children next to each other, from start to end. Column places them one under the other, from top to bottom. Most screens are made of these two.

Row(
    horizontalArrangement = Arrangement.spacedBy(8.dp),
    verticalAlignment = Alignment.CenterVertically,
) {
    Icon(Icons.Filled.Star, contentDescription = null)
    Text("Favorites")
}

Two ideas set where children go:

Inside the content, children get extra modifiers from RowScope or ColumnScope:

A Row or Column doesn't scroll. Add Modifier.horizontalScroll(...) or Modifier.verticalScroll(...), or use LazyRow or LazyColumn for long lists.

When children don't fit in one line, use FlowRow: it wraps to the next line.

Parameters

@Composable
fun Row(
    modifier: Modifier = Modifier,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    verticalAlignment: Alignment.Vertical = Alignment.Top,
    content: @Composable RowScope.() -> Unit,
)

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. See the Modifier guide.

horizontalArrangement: Arrangement.HorizontalOptional

Default: Arrangement.Start

How children are spread from start to end. Arrangement.spacedBy(8.dp) puts 8 dp between them; SpaceBetween pushes the first and last to the edges. In a Row this is the main direction. The space is only visible when the Row is wider than its children, for example with fillMaxWidth().

verticalAlignment: Alignment.VerticalOptional

Default: Alignment.Top

How children line up vertically: Alignment.Top, CenterVertically or Bottom.

content: @Composable RowScope.() -> UnitRequired

The children. Each composable you call inside is one child, in order.

Linear layouts