---
title: "size"
description: "Sets the preferred width and height of the component."
type: "function"
lastmod: "2026-05-20T01:13:53.256759Z"
---
## API Reference

### size

> Source set: Common

```kotlin
@ExperimentalFoundationStyleApi
fun SizeScope.size(width: Dp, height: Dp)
```

Sets the preferred width and height of the component. The actual size will also depend on the
parent's constraints and other modifiers. The specified dimensions includes both [contentPadding](/jetpack-compose/androidx.compose.foundation/foundation/functions/contentPadding)
and [externalPadding](/jetpack-compose/androidx.compose.foundation/foundation/functions/externalPadding).

This property is *not* inherited

#### Parameters

| | |
| --- | --- |
| width | The preferred width in Dp. |
| height | The preferred height in Dp. |

### size

> Source set: Common

```kotlin
@ExperimentalFoundationStyleApi
fun SizeScope.size(value: Dp)
```

Sets the preferred width and height of the component to the same value. The actual size will also
depend on the parent's constraints and other modifiers. The specified size includes any padding.

This property is *not* inherited

#### Parameters

| | |
| --- | --- |
| value | The preferred width and height in Dp. |

### size

> Source set: Common

```kotlin
@ExperimentalFoundationStyleApi
fun SizeScope.size(value: DpSize)
```

Sets the preferred width and height of the component using a [DpSize](/jetpack-compose/androidx.compose.ui/ui-unit/functions/DpSize) object. The actual size
will also depend on the parent's constraints and other modifiers. The specified size includes any
padding.

This property is *not* inherited

#### Parameters

| | |
| --- | --- |
| value | The preferred size. |
