# Dimension.Companion

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.Companion&ss=androidx/platform/frameworks/support)

# Dimension.Companion

*** ** * ** ***

Kotlin\|Java

<br />

```
object Dimension.Companion
```

<br />

*** ** * ** ***

## Summary

|                                                       ### Public functions                                                        |
|-----------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)                           | [percent](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#percent(kotlin.Float))`(percent: `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` A[Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)that is a percent of the parent in the corresponding direction. |
| [Dimension.MinCoercible](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.MinCoercible) | [preferredValue](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#preferredValue(androidx.compose.ui.unit.Dp))`(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.                                         |
| [Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)                           | [ratio](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#ratio(kotlin.String))`(ratio: `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the dimensions to be defined as a ratio of the width and height.                                                                                                      |
| [Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)                           | [value](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#value(androidx.compose.ui.unit.Dp))`(dp: `[Dp](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)`)` Creates a[Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)representing a fixed dp size.                   |

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

## Public functions

### percent

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

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

### 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[Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)such that if the constraints allow it, will have the size given by[dp](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[fillToConstraints](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#fillToConstraints())with a max value.

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

### ratio

```
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[fillToConstraints](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#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[Dimension](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[ConstraintSet](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet).

## Public properties

### fillToConstraints

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

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

A[Dimension](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension)that spreads to match constraints.  

### matchParent

```
val matchParent: Dimension
```

A fixed[Dimension](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[ConstraintSet](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet).  

### preferredWrapContent

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

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

A[Dimension](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[ConstraintSet](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet)do not allow it. To make the value fixed (respected regardless the[ConstraintSet](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet)),[wrapContent](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Dimension.Companion#wrapContent())should be used instead.  

### wrapContent

```
val wrapContent: Dimension
```

A fixed[Dimension](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[ConstraintSet](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet).