Box

Composable Function

Common
@Composable
inline fun Box(
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    propagateMinConstraints: Boolean = false,
    content: @Composable BoxScope.() -> Unit,
)

A layout composable with content. The Box will size itself to fit the content, subject to the incoming constraints. When children are smaller than the parent, by default they will be positioned inside the Box according to the contentAlignment. For individually specifying the alignments of the children layouts, use the BoxScope.align modifier. By default, the content will be measured without the Box's incoming min constraints, unless propagateMinConstraints is true. As an example, setting propagateMinConstraints to true can be useful when the Box has content on which modifiers cannot be specified directly and setting a min size on the content of the Box is needed. If propagateMinConstraints is set to true, the min size set on the Box will also be applied to the content, whereas otherwise the min size will only apply to the Box. When the content has more than one layout child the layout children will be stacked one on top of the other (positioned as explained above) in the composition order.

Parameters

modifierThe modifier to be applied to the layout.
contentAlignmentThe default alignment inside the Box.
propagateMinConstraintsWhether the incoming min constraints should be passed to content.
contentThe content of the Box.
Common
@Composable
fun Box(modifier: Modifier)

A box with no content that can participate in layout, drawing, pointer input due to the modifier applied to it.

Parameters

modifierThe modifier to be applied to the layout.