# requiredHeight

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/requiredHeight.modifier#(androidx.compose.ui.Modifier).requiredHeight(androidx.compose.ui.unit.Dp)(height: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Declare the height of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredHeight(androidx.compose.ui.unit.Dp)`dp. | 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/requiredHeight.modifier#(androidx.compose.ui.Modifier).requiredHeight(androidx.compose.foundation.layout.IntrinsicSize)(intrinsicSize: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/IntrinsicSize)` Declare the height of the content to be exactly the same as the min or max intrinsic height of the content. | Cmn |

## Functions

### Modifier.requiredHeight

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:requiredHeight) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0)

```
fun Modifier.requiredHeight(height: Dp): Modifier
```

Declare the height of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).requiredHeight(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/requiredHeightIn.modifier#(androidx.compose.ui.Modifier).requiredHeightIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` and `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).requiredHeight(androidx.compose.ui.unit.Dp)` to set a preferred height, 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.aspectRatio
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.requiredHeight
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 blue box centered in a 100.dp x 100.dp space.
// Note that although a previous modifier asked it to be 100.dp height, this
// will not be respected. They would be respected if height was used instead of requiredHeight.
Box(
    Modifier.requiredHeight(100.dp).requiredHeight(50.dp).aspectRatio(1f).background(Color.Blue)
)
```

### Modifier.requiredHeight

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/Intrinsic.kt+function:requiredHeight) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
fun Modifier.requiredHeight(intrinsicSize: IntrinsicSize): Modifier
```

Declare the height of the content to be exactly the same as the min or max intrinsic height of the content. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` will not override this value. If the content intrinsic height 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/width.modifier#(androidx.compose.ui.Modifier).width(androidx.compose.foundation.layout.IntrinsicSize)` for options of sizing to intrinsic width. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/height.modifier#(androidx.compose.ui.Modifier).height(androidx.compose.foundation.layout.IntrinsicSize)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/heightIn.modifier#(androidx.compose.ui.Modifier).heightIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` for options to set the preferred height. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredHeight.modifier#(androidx.compose.ui.Modifier).requiredHeight(androidx.compose.foundation.layout.IntrinsicSize)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredHeightIn.modifier#(androidx.compose.ui.Modifier).requiredHeightIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` for other options to set the required height.