New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Compose Foundation Layout



Allow the content to measure at its desired size without regard for the incoming measurement [minimum width][Constraints.minWidth] or [minimum height][Constraints.minHeight] constraints, and, if [unbounded] is true, also without regard for the incoming maximum constraints. If the content's measured size is smaller than the minimum size constraint, [align] it within that minimum sized space. If the content's measured size is larger than the maximum size constraint (only possible when [unbounded] is true), [align] within the maximum space.

Last updated:


dependencies {


fun Modifier.wrapContentSize(
    align: Alignment = Alignment.Center,
    unbounded: Boolean = false

Code Example


fun SimpleWrapContentAlignedModifier() {
    // Here the result will be a 20.dp x 20.dp blue box top-centered in a 40.dp x 40.dp space.
    // Because of the sizeIn modifier, if wrapContentSize did not exist, the blue rectangle
    // would actually be 40.dp x 40.dp to satisfy the min size set by the modifier. However,
    // because we provide wrapContentSize, the blue rectangle is specified to be wrap
    // content - if the desired size is smaller than 40.dp x 40.dp, it will be top-centered in
    // this space. Therefore the 20.dp x 20.dp is top-centered in the space.
        Modifier.sizeIn(minWidth = 40.dp, minHeight = 40.dp)