<div class='type'>Compose Modifier</div>

<a id='references'></a>


<h2 id="requiredsize-size">requiredSize</h2>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Modifier.requiredSize(size: Dp) =
    this.then(
        SizeElement(
            minWidth = size,
            maxWidth = size,
            minHeight = size,
            maxHeight = size,
            enforceIncoming = false,
            inspectorInfo =
                debugInspectorInfo {
                    name = "requiredSize"
                    value = size
                },
        )
    )
```


Declare the size of the content to be exactly `size`dp width and height. The incoming measurement
`Constraints` will not override this value. If the content chooses a size that does not satisfy
the incoming `Constraints`, the parent layout will be reported a size coerced in the
`Constraints`, and the position of the content will be automatically offset to be centered on the
space assigned to the child by the parent layout under the assumption that `Constraints` were
respected.

See `requiredSizeIn` to set a size range. See `size` to set a preferred size, which is only
respected when the incoming constraints allow it.





<hr class="docs-overload-divider">


<h2 id="requiredsize-width-height">requiredSize</h2>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Modifier.requiredSize(width: Dp, height: Dp) =
    this.then(
        SizeElement(
            minWidth = width,
            maxWidth = width,
            minHeight = height,
            maxHeight = height,
            enforceIncoming = false,
            inspectorInfo =
                debugInspectorInfo {
                    name = "requiredSize"
                    properties["width"] = width
                    properties["height"] = height
                },
        )
    )
```


Declare the size of the content to be exactly `width`dp and `height`dp. The incoming measurement
`Constraints` will not override this value. If the content chooses a size that does not satisfy
the incoming `Constraints`, the parent layout will be reported a size coerced in the
`Constraints`, and the position of the content will be automatically offset to be centered on the
space assigned to the child by the parent layout under the assumption that `Constraints` were
respected.

See `requiredSizeIn` to set a size range. See `size` to set a preferred size, which is only
respected when the incoming constraints allow it.





<hr class="docs-overload-divider">


<h2 id="requiredsize-size-2">requiredSize</h2>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Modifier.requiredSize(size: DpSize) = requiredSize(size.width, size.height)
```


Declare the size of the content to be exactly `size`. The incoming measurement `Constraints` will
not override this value. If the content chooses a size that does not satisfy the incoming
`Constraints`, the parent layout will be reported a size coerced in the `Constraints`, and the
position of the content will be automatically offset to be centered on the space assigned to the
child by the parent layout under the assumption that `Constraints` were respected.

See `requiredSizeIn` to set a size range. See `size` to set a preferred size, which is only
respected when the incoming constraints allow it.