Column, Row and Box are the three basic layout composables in Jetpack Compose. Column places its children vertically, Row places them horizontally, and Box stacks them on top of each other. You control spacing and position with arrangement and alignment parameters. This guide explains the compose column row box layouts with examples you can paste into a project.
Nearly every screen is a nesting of these three, so understanding how they size and place children is the key skill.
Column arranges its children from top to bottom. Two parameters control placement: verticalArrangement for the main axis (vertical) and horizontalAlignment for the cross axis (horizontal).
Arrangement.spacedBy(8.dp) puts a gap between children. Other arrangements include Top, Center, Bottom, SpaceBetween, SpaceAround and SpaceEvenly. A Column does not scroll by default. For scrolling, add Modifier.verticalScroll(rememberScrollState()) for short content, or use LazyColumn for long lists.
Row is the same idea on the other axis. horizontalArrangement controls the main axis (horizontal), and verticalAlignment controls the cross axis (vertical).
SpaceBetween pushes the first child to the start and the last to the end. A Row clips nothing and does not wrap. If children are wider than the row, they overflow, so use Modifier.weight or FlowRow for wrapping content.
Inside a Row or Column, Modifier.weight(1f) gives a child a share of the remaining space after fixed-size children are measured.
The first text takes everything the second one does not need.
Box draws its children in order, each on top of the previous. It is the Compose equivalent of a frame layout. Use contentAlignment to position all children, or Modifier.align on a single child.
The blue box is drawn first, and the badge is drawn above it in the top-right corner. Modifier.matchParentSize() is available in BoxScope and makes a child match the box size without influencing it, which is handy for overlays and backgrounds.
| Layout | Main axis | Main axis control | Cross axis control | Typical use |
|---|---|---|---|---|
Column | Vertical | verticalArrangement | horizontalAlignment | Forms, lists of short items, screen content |
Row | Horizontal | horizontalArrangement | verticalAlignment | Toolbars, icon with label, buttons side by side |
Box | None (stacked) | contentAlignment | Modifier.align | Overlays, badges, centring one child |
Arrangement distributes children along the main axis, and alignment positions each child on the cross axis. Mixing them up is the most common beginner mistake.
Real screens nest these composables:
A few practical rules:
fillMaxWidth() or fillMaxSize() when you want arrangement and alignment to have room to work. A Column is only as wide as its widest child by default.Arrangement.spacedBy over adding padding to each child.LazyColumn and LazyRow for long or unknown-length lists, because plain Column composes every child at once.FlowRow and FlowColumn. For responsive screens use BoxWithConstraints or window size classes.Arrangement spaces children along the main axis of a Column or Row. Alignment places them on the cross axis. In a Column, verticalArrangement is the main axis and horizontalAlignment the cross axis.
A Column wraps its content by default. Add Modifier.fillMaxSize() and then verticalArrangement = Arrangement.Center and horizontalAlignment = Alignment.CenterHorizontally.
Add Modifier.verticalScroll(rememberScrollState()) for small content. For long lists use LazyColumn.
Use Box when children should overlap, such as a badge on an image, a loading spinner over content or a single centred child.
Column stacks vertically, Row lines up horizontally and Box overlaps its children. Use Arrangement for spacing on the main axis, Alignment for the cross axis, and Modifier.weight to share space. Nest them to build real screens and switch to lazy lists when the content is long.