# Size

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

  ```
  value class Size
  ```

*** ** * ** ***

Holds a 2D floating-point size.

You can think of this as an `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` from the origin.

To create a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`, call the top-level function that accepts a width/height pair of dimensions:

```kotlin
val size = Size(width, height)
```

The primary constructor of `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` is intended to be used with the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#packedValue()` property to allow storing sizes in arrays or collections of primitives without boxing.

## Summary

| ### Nested types |
|---|
| `object https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.Companion` |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#Unspecified()` A size whose `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` are unspecified. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#Zero()` An empty size, one with a zero width and a zero height. | Cmn |

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

| ### Public functions |
|---|---|---|
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#component1()()` | Cmn |
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#component2()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#copy(kotlin.Float,kotlin.Float)(width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Returns a copy of this Size instance optionally overriding the width or height parameter | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#div(kotlin.Float)(operand: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Division operator. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#isEmpty()()` Whether this size encloses a non-zero area. | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#times(kotlin.Float)(operand: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Multiplication operator. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#maxDimension()` The greater of the magnitudes of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#minDimension()` The lesser of the magnitudes of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#packedValue()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` value encoding the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` components of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).roundToIntSize()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to an `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).toIntSize()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to an `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize`. | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).div(androidx.compose.ui.layout.ScaleFactor)(scaleFactor: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ScaleFactor)` Division operator with `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).times(androidx.compose.ui.layout.ScaleFactor)(scaleFactor: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ScaleFactor)` Multiplication operator with `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. | Cmn |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).takeOrElse(kotlin.Function0)(block: () -> https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size)` If this `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Offset).isSpecified()` then this is returned, otherwise `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Size).takeOrElse(kotlin.Function0)` is executed and its result is returned. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).toRect()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect`. | Cmn |

| ### Extension properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).center()` Returns the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` of the center of the rect from the point of 0, 0 with this `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).isSpecified()` `false` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#(androidx.compose.ui.geometry.Size).isUnspecified()` `true` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#Unspecified()`. | Cmn |

## Public companion properties

### Unspecified

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

```
val Unspecified: Size
```

A size whose `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` are unspecified. This is a sentinel value used to initialize a non-null parameter. Access to width or height on an unspecified size is not allowed.

### Zero

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

```
val Zero: Size
```

An empty size, one with a zero width and a zero height.

## Public constructors

### Size

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

```
Size(packedValue: Long)
```

| Parameters |
|---|---|
| `packedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` value encoding the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` components of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. Encoded values can be obtained by using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#packedValue()` property of existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` instances. |

## Public functions

### component1

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

```
inline operator fun component1(): Float
```

### component2

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

```
inline operator fun component2(): Float
```

### copy

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

```
fun copy(
    width: Float = unpackFloat1(packedValue),
    height: Float = unpackFloat2(packedValue)
): Size
```

Returns a copy of this Size instance optionally overriding the width or height parameter

### div

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

```
operator fun div(operand: Float): Size
```

Division operator.

Returns a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` whose dimensions are the dimensions of the left-hand-side operand (a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`) divided by the scalar right-hand-side operand (a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html`).

### isEmpty

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

```
fun isEmpty(): Boolean
```

Whether this size encloses a non-zero area.

Negative areas are considered empty.

### times

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

```
operator fun times(operand: Float): Size
```

Multiplication operator.

Returns a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` whose dimensions are the dimensions of the left-hand-side operand (a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`) multiplied by the scalar right-hand-side operand (a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html`).

### toString

Cmn

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

## Public properties

### height

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

```
val height: Float
```

### maxDimension

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

```
val maxDimension: Float
```

The greater of the magnitudes of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()`.

### minDimension

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

```
val minDimension: Float
```

The lesser of the magnitudes of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()`.

### packedValue

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

```
val packedValue: Long
```

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` value encoding the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` components of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. Encoded values can be obtained by using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#packedValue()` property of existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` instances.

### width

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

```
val width: Float
```

## Extension functions

### Size.roundToIntSize

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/IntSize.kt+function:roundToIntSize)

```
fun Size.roundToIntSize(): IntSize
```

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to an `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize`. This rounds `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#width()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#height()` to the nearest integer.

### Size.toIntSize

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/IntSize.kt+function:toIntSize)

```
fun Size.toIntSize(): IntSize
```

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to an `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize`. This rounds the width and height values down to the nearest integer.

### Size.div

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

```
operator fun Size.div(scaleFactor: ScaleFactor): Size
```

Division operator with `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`

Return a new `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` with the width and height divided by `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ScaleFactor#scaleX()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ScaleFactor#scaleY()` respectively

### Size.times

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

```
operator fun Size.times(scaleFactor: ScaleFactor): Size
```

Multiplication operator with `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`.

Return a new `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` with the width and height multiplied by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ScaleFactor#scaleX()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ScaleFactor#scaleY()` respectively

### Size.takeOrElse

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

```
inline fun Size.takeOrElse(block: () -> Size): Size
```

If this `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Offset).isSpecified()` then this is returned, otherwise `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Size).takeOrElse(kotlin.Function0)` is executed and its result is returned.

### Size.toRect

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

```
fun Size.toRect(): Rect
```

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect`.

## Extension properties

### Size.center

Cmn Artifact: [androidx.compose.ui:ui-geometry](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/geometry/Size.kt+symbol:center)

```
val Size.center: Offset
```

Returns the `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` of the center of the rect from the point of 0, 0 with this `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`.

### Size.isSpecified

Cmn Artifact: [androidx.compose.ui:ui-geometry](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/geometry/Size.kt+symbol:isSpecified)

```
val Size.isSpecified: Boolean
```

`false` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#Unspecified()`.

### Size.isUnspecified

Cmn Artifact: [androidx.compose.ui:ui-geometry](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/geometry/Size.kt+symbol:isUnspecified)

```
val Size.isUnspecified: Boolean
```

`true` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size#Unspecified()`.