# requiredSize

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSize.modifier#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Declare the size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)`dp width and height. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSize.modifier#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.DpSize)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize)` Declare the size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.DpSize)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSize.modifier#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)(width: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, height: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Declare the size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp. | Cmn |

## Functions

### Modifier.requiredSize

Cmn Artifact: [androidx.compose.foundation:foundation-layout](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/layout/Size.kt+function:requiredSize) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0)

```
fun Modifier.requiredSize(size: Dp): Modifier
```

Declare the size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)`dp width and height. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` will not override this value. If the content chooses a size that does not satisfy the incoming `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, the parent layout will be reported a size coerced in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` were respected.

See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSizeIn.modifier#(androidx.compose.ui.Modifier).requiredSizeIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set a size range. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)` to set a preferred size, which is only respected when the incoming constraints allow it.

Example usage:

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

// The result is a 50.dp x 50.dp red box centered in a 100.dp x 100.dp space.
// Note that although a previous modifier asked it to be 100.dp x 100.dp, this
// will not be respected. They would be respected if size was used instead of requiredSize.
Box(Modifier.requiredSize(100.dp, 100.dp).requiredSize(50.dp, 50.dp).background(Color.Red))
```

### Modifier.requiredSize

Cmn Artifact: [androidx.compose.foundation:foundation-layout](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/layout/Size.kt+function:requiredSize) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0)

```
fun Modifier.requiredSize(size: DpSize): Modifier
```

Declare the size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.DpSize)`. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` will not override this value. If the content chooses a size that does not satisfy the incoming `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, the parent layout will be reported a size coerced in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` were respected.

See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSizeIn.modifier#(androidx.compose.ui.Modifier).requiredSizeIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set a size range. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.DpSize)` to set a preferred size, which is only respected when the incoming constraints allow it.

### Modifier.requiredSize

Cmn Artifact: [androidx.compose.foundation:foundation-layout](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/layout/Size.kt+function:requiredSize) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0)

```
fun Modifier.requiredSize(width: Dp, height: Dp): Modifier
```

Declare the size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` will not override this value. If the content chooses a size that does not satisfy the incoming `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, the parent layout will be reported a size coerced in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` were respected.

See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSizeIn.modifier#(androidx.compose.ui.Modifier).requiredSizeIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set a size range. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp)` to set a preferred size, which is only respected when the incoming constraints allow it.