Composable Function

SpatialBox

A layout composable that sizes itself to fit its content, subject to incoming constraints.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free

SpatialBox

Android
@Composable
@SubspaceComposable
public inline fun SpatialBox(
    modifier: SubspaceModifier = SubspaceModifier,
    alignment: SpatialAlignment = SpatialAlignment.Center,
    propagateMinConstraints: Boolean = false,
    crossinline content: @Composable @SubspaceComposable SpatialBoxScope.() -> Unit,
)

A layout composable that sizes itself to fit its content, subject to incoming constraints.

A layout composable with content. The SpatialBox 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 SpatialBox according to the alignment. For individually specifying the alignments of the children layouts, use the SpatialBoxScope.align modifier. By default, the content will be measured without the SpatialBox's incoming min constraints. If propagateMinConstraints is set to true, the min size set on the SpatialBox will also be applied to the content.

Note: If the content has multiple children, they might overlap depending on their positioning.

Parameters

modifier The modifier to be applied to the layout.
alignment The default alignment of children within the SpatialBox.
propagateMinConstraints Whether the incoming min constraints should be passed to content.
content The content of the SpatialBox.