# size

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/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Declare the preferred size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp)`dp square. | 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/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.DpSize)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize)` Declare the preferred size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.DpSize)`. | 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/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)(width: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, height: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Declare the preferred size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp. | Cmn |

## Functions

### Modifier.size

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

```
fun Modifier.size(size: Dp): Modifier
```

Declare the preferred size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp)`dp square. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` may override this value, forcing the content to be either smaller or larger.

For a modifier that sets the size of the content regardless of the incoming constraints, see `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSize.modifier#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)`. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/width.modifier#(androidx.compose.ui.Modifier).width(androidx.compose.foundation.layout.IntrinsicSize)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/height.modifier#(androidx.compose.ui.Modifier).height(androidx.compose.foundation.layout.IntrinsicSize)` to set width or height alone. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/widthIn.modifier#(androidx.compose.ui.Modifier).widthIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`, `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)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/sizeIn.modifier#(androidx.compose.ui.Modifier).sizeIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set a preferred size range.

Example usage:

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

Box { Box(Modifier.size(100.dp, 100.dp).background(Color.Red)) }
```

### Modifier.size

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

```
fun Modifier.size(size: DpSize): Modifier
```

Declare the preferred size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/size.modifier#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.DpSize)`. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` may override this value, forcing the content to be either smaller or larger.

For a modifier that sets the size of the content regardless of the incoming constraints, see `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSize.modifier#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)`. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/width.modifier#(androidx.compose.ui.Modifier).width(androidx.compose.foundation.layout.IntrinsicSize)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/height.modifier#(androidx.compose.ui.Modifier).height(androidx.compose.foundation.layout.IntrinsicSize)` to set width or height alone. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/widthIn.modifier#(androidx.compose.ui.Modifier).widthIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`, `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)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/sizeIn.modifier#(androidx.compose.ui.Modifier).sizeIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set a preferred size range.

Example usage:

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp

Box { Box(Modifier.size(DpSize(100.dp, 100.dp)).background(Color.Red)) }
```

### Modifier.size

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

```
fun Modifier.size(width: Dp, height: Dp): Modifier
```

Declare the preferred size of the content to be exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`dp. The incoming measurement `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Constraints` may override this value, forcing the content to be either smaller or larger.

For a modifier that sets the size of the content regardless of the incoming constraints, see `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/requiredSize.modifier#(androidx.compose.ui.Modifier).requiredSize(androidx.compose.ui.unit.Dp)`. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).size(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set width or height alone. See `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/widthIn.modifier#(androidx.compose.ui.Modifier).widthIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`, `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)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/sizeIn.modifier#(androidx.compose.ui.Modifier).sizeIn(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` to set a preferred size range.

Example usage:

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

Box { Box(Modifier.size(100.dp, 100.dp).background(Color.Red)) }
```