---
title: "constrainHeight"
description: "Takes a height and returns the closest size to it that satisfies the constraints."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Constraints.constrainHeight(height: Int) = height.fastCoerceIn(minHeight, maxHeight)
```


Takes a height and returns the closest size to it that satisfies the constraints.



