New Compose Multiplatform components arrived on Composables UICheck it out →

Column

A layout composable that places its children in a vertical sequence. For a layout composable that places its children in a horizontal sequence, see [Row]. Note that by default items do not scroll; see Modifier.verticalScroll to add this behavior. For a vertically scrollable list that only composes and lays out the currently visible items see LazyColumn.

The [Column] layout is able to assign children heights according to their weights provided using the [ColumnScope.weight] modifier. If a child is not provided a weight, it will be asked for its preferred height before the sizes of the children with weights are calculated proportionally to their weight based on the remaining available space. Note that if the [Column] is vertically scrollable or part of a vertically scrollable container, any provided weights will be disregarded as the remaining available space will be infinite.

When none of its children have weights, a [Column] will be as small as possible to fit its children one on top of the other. In order to change the height of the [Column], use the [Modifier.height] modifiers; e.g. to make it fill the available height [Modifier.fillMaxHeight] can be used. If at least one child of a [Column] has a [weight][ColumnScope.weight], the [Column] will fill the available height, so there is no need for [Modifier.fillMaxHeight]. However, if [Column]'s size should be limited, the [Modifier.height] or [Modifier.size] layout modifiers should be applied.

When the size of the [Column] is larger than the sum of its children sizes, a [verticalArrangement] can be specified to define the positioning of the children inside the [Column]. See [Arrangement] for available positioning behaviors; a custom arrangement can also be defined using the constructor of [Arrangement]. Below is an illustration of different vertical arrangements:

Column arrangements

Last updated:

Installation

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

Overloads

@Composable
fun Column(
    modifier: Modifier = Modifier,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    content: @Composable ColumnScope.() -> Unit
)

Parameters

namedescription
modifierThe modifier to be applied to the Column.
verticalArrangementThe vertical arrangement of the layout's children.
horizontalAlignmentThe horizontal alignment of the layout's children.

Code Example

SimpleColumn

@Composable
@Sampled
fun SimpleColumn() {
    Column {
        // The child with no weight will have the specified size.
        Box(Modifier.size(40.dp, 80.dp).background(Color.Magenta))
        // Has weight, the child will occupy half of the remaining height.
        Box(Modifier.width(40.dp).weight(1f).background(Color.Yellow))
        // Has weight and does not fill, the child will occupy at most half of the remaining height.
        // Therefore it will occupy 80.dp (its preferred height) if the assigned height is larger.
        Box(
            Modifier.size(40.dp, 80.dp)
                .weight(1f, fill = false)
                .background(Color.Green)
        )
    }
}