A composable that defines its own content according to the available space, based on the incoming constraints or the current [LayoutDirection].
BoxWithConstraintsSample
@Composable
fun BoxWithConstraintsSample() {
BoxWithConstraints {
val rectangleHeight = 100.dp
if (maxHeight < rectangleHeight * 2) {
Box(Modifier.size(50.dp, rectangleHeight).background(Color.Blue))
} else {
Column {
Box(Modifier.size(50.dp, rectangleHeight).background(Color.Blue))
Box(Modifier.size(50.dp, rectangleHeight).background(Color.Gray))
}
}
}
}