'Wrap content but with minimum width/height - Jetpack Compose

I have a Box and some Text in it. The Text is actually just a number, which can be 1, 2, or 3 digits. On the one hand, I want to wrap the content to accommodate for the case where we get a 3 digit number (which would make the box wider), but on the other hand, if we get a 1 digit number, the box becomes very skinny and looks visually awkward.

I've tried Modifier.width(Int.dp) and Modifier.wrapContentWidth() and even a combination of the two, but can't get it to behave right. Is there a way in Compose to wrap the content, but with a minimum (default) width or height?

I'd rather not use an if - else statement on the input size if at all possible, since that would sort of defeat the purpose.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source