# Constraints

Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+class:androidx.compose.ui.unit.Constraints) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  value class Constraints
  ```

*** ** * ** ***

Immutable constraints for measuring layouts, used by `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Layout.composable#Layout(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.layout.MeasurePolicy)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/LayoutModifier` to measure their layout children. The parent chooses the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` defining a range, in pixels, within which the measured layout should choose a size:

- `minWidth`\<= `chosenWidth`\<= `maxWidth`

- `minHeight`\<= `chosenHeight`\<= `maxHeight`

For more details about how layout measurement works, see `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasurePolicy` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/LayoutModifier#(androidx.compose.ui.layout.MeasureScope).measure(androidx.compose.ui.layout.Measurable,androidx.compose.ui.unit.Constraints)`.

A set of `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` can have infinite maxWidth and/or maxHeight. This is a trick often used by parents to ask their children for their preferred size: unbounded constraints force children whose default behavior is to fill the available space (always size to maxWidth/maxHeight) to have an opinion about their preferred size. Most commonly, when measured with unbounded `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, these children will fallback to size themselves to wrap their content, instead of expanding to fill the available space (this is not always true as it depends on the child layout model, but is a common behavior for core layout components).

`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` uses a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` to represent four values, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minWidth()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minHeight()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()`. The range of the values varies to allow for at most 256K in one dimension. There are four possible maximum ranges, 13 bits/18 bits, and 15 bits/16 bits for either width or height, depending on the needs. For example, a width could range up to 18 bits and the height up to 13 bits. Alternatively, the width could range up to 16 bits and the height up to 15 bits. The height and width requirements can be reversed, with a height of up to 18 bits and width of 13 bits or height of 16 bits and width of 15 bits. Any constraints exceeding this range will fail.

## Summary

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` A value that `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` will be set to when the constraint should be considered infinite. | Cmn |

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#fitPrioritizingHeight(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)( minWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` that match as close as possible to the values passed. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#fitPrioritizingWidth(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)( minWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` that match as close as possible to the values passed. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#fixed(kotlin.Int,kotlin.Int)(width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates constraints for fixed size in both dimensions. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#fixedHeight(kotlin.Int)(height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates constraints for fixed height and unspecified width. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#fixedWidth(kotlin.Int)(width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates constraints for fixed width and unspecified height. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `[restrictConstraints](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#restrictConstraints(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Boolean))( minWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, prioritizeWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** Replace with fitPrioritizingWidth | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Constraints(kotlin.Long)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)(minWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Copies the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, replacing some of `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` as desired. | Cmn |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copyMaxDimensions()()` Copies the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, setting `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minWidth()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minHeight()` to 0, and preserving `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` as-is. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasBoundedHeight()` `false` when `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` and `true` if `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` is a non-`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` value. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasBoundedWidth()` `false` when `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` and `true` if `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` is a non-`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` value. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasFixedHeight()` Whether there is exactly one height value that satisfies the constraints. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasFixedWidth()` Whether there is exactly one width value that satisfies the constraints. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#isZero()` Whether the area of a component respecting these constraints will definitely be 0. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` The maximum height that the measurement can take, in pixels. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` The maximum width that the measurement can take, in pixels. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minHeight()` The minimum height that the measurement can take, in pixels. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minWidth()` The minimum width that the measurement can take, in pixels. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#(androidx.compose.ui.unit.Constraints).constrain(androidx.compose.ui.unit.Constraints)(otherConstraints: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints)` Takes `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/package-summary#(androidx.compose.ui.unit.Constraints).constrain(androidx.compose.ui.unit.Constraints)` and returns the result of coercing them in the current constraints. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#(androidx.compose.ui.unit.Constraints).constrain(androidx.compose.ui.unit.IntSize)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize)` Takes a size and returns the closest size to it that satisfies the constraints. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#(androidx.compose.ui.unit.Constraints).constrainHeight(kotlin.Int)(height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Takes a height and returns the closest size to it that satisfies the constraints. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#(androidx.compose.ui.unit.Constraints).constrainWidth(kotlin.Int)(width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Takes a width and returns the closest size to it that satisfies the constraints. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#(androidx.compose.ui.unit.Constraints).isSatisfiedBy(androidx.compose.ui.unit.IntSize)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize)` Takes a size and returns whether it satisfies the current constraints. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#(androidx.compose.ui.unit.Constraints).offset(kotlin.Int,kotlin.Int)(horizontal: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, vertical: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the Constraints obtained by offsetting the current instance with the given values. | Cmn |

## Constants

### Infinity

Cmn

```
const val Infinity: Int
```

A value that `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` will be set to when the constraint should be considered infinite. `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasBoundedWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasBoundedHeight()` will be `false` when `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()`, respectively.

## Public companion functions

### fitPrioritizingHeight

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun fitPrioritizingHeight(
    minWidth: Int,
    maxWidth: Int,
    minHeight: Int,
    maxHeight: Int
): Constraints
```

Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` that match as close as possible to the values passed. If the dimensions are outside of those that can be represented, the constraints are limited to those that can be represented.

`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` is a `value class` based on a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` and 4 integers must be limited to fit within its size. The larger dimension has up to 18 bits (262,143) and the smaller as few as 13 bits (8191). The height is granted as much space as it needs or caps the size to 18 bits. The width is given the remaining space.

This can be useful when layout constraints are possible to be extremely large, but not everything is possible to display on the device. For example a text layout where an entire chapter of a book is measured in one Layout and it isn't possible to break up the content to show in a `LazyColumn`.

### fitPrioritizingWidth

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun fitPrioritizingWidth(
    minWidth: Int,
    maxWidth: Int,
    minHeight: Int,
    maxHeight: Int
): Constraints
```

Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` that match as close as possible to the values passed. If the dimensions are outside of those that can be represented, the constraints are limited to those that can be represented.

`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` is a `value class` based on a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` and 4 integers must be limited to fit within its size. The larger dimension has up to 18 bits (262,143) and the smaller as few as 13 bits (8191). The width is granted as much space as it needs or caps the size to 18 bits. The height is given the remaining space.

This can be useful when layout constraints are possible to be extremely large, but not everything is possible to display on the device. For example a text layout where an entire chapter of a book is measured in one Layout and it isn't possible to break up the content to show in a `LazyColumn`.

### fixed

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun fixed(width: Int, height: Int): Constraints
```

Creates constraints for fixed size in both dimensions.

### fixedHeight

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun fixedHeight(height: Int): Constraints
```

Creates constraints for fixed height and unspecified width.

### fixedWidth

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun fixedWidth(width: Int): Constraints
```

Creates constraints for fixed width and unspecified height.

### restrictConstraints

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [restrictConstraints](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#restrictConstraints(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Boolean))(
    minWidth: Int,
    maxWidth: Int,
    minHeight: Int,
    maxHeight: Int,
    prioritizeWidth: Boolean = true
): Constraints
```

> [!CAUTION]
> **This function is deprecated.**   
> Replace with fitPrioritizingWidth, use this instead:
>
> ```kotlin
> Constraints.fitPrioritizingWidth(minWidth, maxWidth, minHeight, maxHeight)
> ```

## Public constructors

### Constraints

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
Constraints(value: Long)
```

## Public functions

### copy

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
fun copy(
    minWidth: Int = this.minWidth,
    maxWidth: Int = this.maxWidth,
    minHeight: Int = this.minHeight,
    maxHeight: Int = this.maxHeight
): Constraints
```

Copies the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, replacing some of `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` as desired. `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` must be positive and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` must be greater than or equal to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#copy(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)`, respectively, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()`.

### copyMaxDimensions

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
inline fun copyMaxDimensions(): Constraints
```

Copies the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints`, setting `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minWidth()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minHeight()` to 0, and preserving `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` as-is.

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### hasBoundedHeight

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val hasBoundedHeight: Boolean
```

`false` when `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` and `true` if `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxHeight()` is a non-`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` value.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasBoundedWidth()` |   |

### hasBoundedWidth

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val hasBoundedWidth: Boolean
```

`false` when `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` and `true` if `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#maxWidth()` is a non-`https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()` value.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#hasBoundedHeight()` |   |

### hasFixedHeight

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val hasFixedHeight: Boolean
```

Whether there is exactly one height value that satisfies the constraints.

### hasFixedWidth

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val hasFixedWidth: Boolean
```

Whether there is exactly one width value that satisfies the constraints.

### isZero

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val isZero: Boolean
```

Whether the area of a component respecting these constraints will definitely be 0. This is true when at least one of maxWidth and maxHeight are 0.

### maxHeight

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val maxHeight: Int
```

The maximum height that the measurement can take, in pixels. This will either be a positive value greater than or equal to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minHeight()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()`.

### maxWidth

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val maxWidth: Int
```

The maximum width that the measurement can take, in pixels. This will either be a positive value greater than or equal to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#minWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints#Infinity()`.

### minHeight

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val minHeight: Int
```

The minimum height that the measurement can take, in pixels.

### minWidth

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val minWidth: Int
```

The minimum width that the measurement can take, in pixels.

## Extension functions

### Constraints.constrain

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+function:constrain)

```
fun Constraints.constrain(otherConstraints: Constraints): Constraints
```

Takes `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/package-summary#(androidx.compose.ui.unit.Constraints).constrain(androidx.compose.ui.unit.Constraints)` and returns the result of coercing them in the current constraints. Note this means that any size satisfying the resulting constraints will satisfy the current constraints, but they might not satisfy the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/package-summary#(androidx.compose.ui.unit.Constraints).constrain(androidx.compose.ui.unit.Constraints)` when the two set of constraints are disjoint. Examples (showing only width, height works the same): (minWidth=2, maxWidth=10).constrain(minWidth=7, maxWidth=12) -\> (minWidth = 7, maxWidth = 10) (minWidth=2, maxWidth=10).constrain(minWidth=11, maxWidth=12) -\> (minWidth=10, maxWidth=10) (minWidth=2, maxWidth=10).constrain(minWidth=5, maxWidth=7) -\> (minWidth=5, maxWidth=7)

### Constraints.constrain

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+function:constrain)

```
fun Constraints.constrain(size: IntSize): IntSize
```

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

### Constraints.constrainHeight

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+function:constrainHeight)

```
fun Constraints.constrainHeight(height: Int): Int
```

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

### Constraints.constrainWidth

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+function:constrainWidth)

```
fun Constraints.constrainWidth(width: Int): Int
```

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

### Constraints.isSatisfiedBy

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+function:isSatisfiedBy)

```
fun Constraints.isSatisfiedBy(size: IntSize): Boolean
```

Takes a size and returns whether it satisfies the current constraints.

### Constraints.offset

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Constraints.kt+function:offset)

```
fun Constraints.offset(horizontal: Int = 0, vertical: Int = 0): Constraints
```

Returns the Constraints obtained by offsetting the current instance with the given values.