Constrain the size of the wrapped layout only when it would be otherwise unconstrained: the [minWidth] and [minHeight] constraints are only applied when the incoming corresponding constraint is 0.
DefaultMinSizeSample
@Composable
fun DefaultMinSizeSample() {
@Composable
fun DefaultMinBox(modifier: Modifier = Modifier) {
Box(modifier.defaultMinSize(minWidth = 100.dp, minHeight = 100.dp).background(Color.Blue))
}
// This will be a 100.dp x 100.dp blue box. Because we are not providing any min constraints
// to the DefaultMinBox, defaultMinSize will apply its min constraints.
DefaultMinBox()
// This will be a 50.dp x 50.dp blue box. Because we are providing min constraints
// to the DefaultMinBox, defaultMinSize will not apply its min constraints.
DefaultMinBox(Modifier.requiredSizeIn(minWidth = 50.dp, minHeight = 50.dp))
// Note that if DefaultMinBox used requiredSizeIn or sizeIn rather than
// defaultMinSize, the min constraints would have been applied with either
// of the above usages.
}