androidx.compose.foundation.layout

FlowRow

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

A FlowRow places children next to each other like a Row, but starts a new line when the next child doesn't fit. Use it for tags, chips or buttons of different widths.

FlowRow(
    horizontalArrangement = Arrangement.spacedBy(8.dp),
    verticalArrangement = Arrangement.spacedBy(8.dp),
) {
    tags.forEach { tag -> AssistChip(onClick = {}, label = { Text(tag) }) }
}

FlowRow creates all children at once. For hundreds of items, use a lazy grid instead.

Parameters

@Composable
fun FlowRow(
    modifier: Modifier = Modifier,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    itemVerticalAlignment: Alignment.Vertical = Alignment.Top,
    maxItemsInEachRow: Int = Int.MAX_VALUE,
    maxLines: Int = Int.MAX_VALUE,
    content: @Composable FlowRowScope.() -> Unit,
)

modifier: ModifierOptional

Default: Modifier

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

horizontalArrangement: Arrangement.HorizontalOptional

Default: Arrangement.Start

In a FlowRow: the space between items in a line. In a FlowColumn: the space between columns.

verticalArrangement: Arrangement.VerticalOptional

Default: Arrangement.Top

In a FlowRow: the space between lines. In a FlowColumn: the space between items in a column.

itemVerticalAlignment: Alignment.VerticalOptionalSince 1.8

Default: Alignment.Top

How items of different heights line up within a line: top, center or bottom.

maxItemsInEachRow: IntOptional

Default: Int.MAX_VALUE

The most items in one line. Then it wraps, even if more would fit.

maxLines: IntOptional

Default: Int.MAX_VALUE

The most lines. Items that don't fit are not shown.

content: @Composable FlowRowScope.() -> UnitRequired

The items.

Flow types