# Dimension

Artifact: [androidx.constraintlayout:constraintlayout-compose](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/compose/ConstraintLayout.kt+class:androidx.constraintlayout.compose.Dimension) Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)


```
interface Dimension
```

<br />

Known direct subclasses [Dimension.Coercible](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Coercible), [Dimension.MaxCoercible](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MaxCoercible), [Dimension.MinCoercible](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MinCoercible)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Coercible` | A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that can be assigned both min and max bounds. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MaxCoercible` | A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that can be assigned a max bound. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MinCoercible` | A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that can be assigned a min bound. |

*** ** * ** ***

Represents a dimension that can be assigned to the width or height of a child`https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference`.

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Coercible : https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that can be assigned both min and max bounds. |
| `interface https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MaxCoercible : https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that can be assigned a max bound. |
| `interface https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MinCoercible : https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that can be assigned a min bound. |

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#percent(kotlin.Float)(percent: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that is a percent of the parent in the corresponding direction. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MinCoercible` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#preferredValue(androidx.compose.ui.unit.Dp)(dp: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Links should be specified from both sides corresponding to this dimension, in order for this to work. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#ratio(kotlin.String)(ratio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the dimensions to be defined as a ratio of the width and height. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#value(androidx.compose.ui.unit.Dp)(dp: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Creates a `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` representing a fixed dp size. |

| ### Public companion properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Coercible` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#fillToConstraints()` Links should be specified from both sides corresponding to this dimension, in order for this to work. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#matchParent()` A fixed `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that matches the dimensions of the root ConstraintLayout. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Coercible` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#preferredWrapContent()` Links should be specified from both sides corresponding to this dimension, in order for this to work. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#wrapContent()` A fixed `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` with wrap content behavior. |

## Public companion functions

### percent

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun percent(percent: Float): Dimension
```

A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that is a percent of the parent in the corresponding direction.

Where 1f is 100% and 0f is 0%.

### preferredValue

```
fun preferredValue(dp: Dp): Dimension.MinCoercible
```

Links should be specified from both sides corresponding to this dimension, in order for this to work.

Creates a `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` such that if the constraints allow it, will have the size given by `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#preferredValue(androidx.compose.ui.unit.Dp)`, otherwise will take the size remaining within the constraints.

This is effectively a shorthand for `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#fillToConstraints()` with a max value.

To make the value fixed (respected regardless the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`), `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#value(androidx.compose.ui.unit.Dp)` should be used instead.

### ratio

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun ratio(ratio: String): Dimension
```

Sets the dimensions to be defined as a ratio of the width and height. The assigned dimension will be considered to also be `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#fillToConstraints()`.

The string to define a ratio is defined by the format: 'W:H'. Where H is the height as a proportion of W (the width).

Eg: width = Dimension.ratio('1:2') sets the width to be half as large as the height.

Note that only one dimension should be defined as a ratio.

### value

```
fun value(dp: Dp): Dimension
```

Creates a `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` representing a fixed dp size. The size will not change according to the constraints in the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`.

## Public companion properties

### fillToConstraints

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val fillToConstraints: Dimension.Coercible
```

Links should be specified from both sides corresponding to this dimension, in order for this to work.

A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that spreads to match constraints.

### matchParent

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val matchParent: Dimension
```

A fixed `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` that matches the dimensions of the root ConstraintLayout. The size will not change accoring to the constraints in the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`.

### preferredWrapContent

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val preferredWrapContent: Dimension.Coercible
```

Links should be specified from both sides corresponding to this dimension, in order for this to work.

A `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` with suggested wrap content behavior. The wrap content size will be respected unless the constraints in the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet` do not allow it. To make the value fixed (respected regardless the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`), `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension#wrapContent()` should be used instead.

### wrapContent

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val wrapContent: Dimension
```

A fixed `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension` with wrap content behavior. The size will not change according to the constraints in the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`.