# WindowSizeClass

Artifact: [androidx.window:window-core](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/core/layout/WindowSizeClass.kt+class:androidx.window.core.layout.WindowSizeClass) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/window#1.1.0)

*** ** * ** ***

Common/All
- Cmn

  ```
  class WindowSizeClass
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` represents breakpoints for a viewport. Designers should design around the different combinations of width and height buckets. Developers should use the different buckets to specify the layouts. Ideally apps will work well in each bucket and by extension work well across multiple devices. If two devices are in similar buckets they should behave similarly.

This class is meant to be a common definition that can be shared across different device types. Application developers can use `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to have standard window buckets and design the UI around those buckets. Library developers can use these buckets to create different UI with respect to each bucket. This will help with consistency across multiple device types.

A library developer use-case can be creating some navigation UI library. For a size class with the `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WIDTH_DP_EXPANDED_LOWER_BOUND()` width it might be more reasonable to have a side navigation.

An application use-case can be applied for apps that use a list-detail pattern. The app can use the `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WIDTH_DP_MEDIUM_LOWER_BOUND()` to determine if there is enough space to show the list and the detail side by side. If all apps follow this guidance then it will present a very consistent user experience.

In some cases developers or UI systems may decide to create their own break points. A developer might optimize for a window that is smaller than the supported break points or larger. A UI system might find that some break points are better suited than the recommended break points. In these cases developers may wish to specify their own custom break points and match using a `when` statement.

To process a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` use the methods `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isAtLeastBreakpoint(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isWidthAtLeastBreakpoint(kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isHeightAtLeastBreakpoint(kotlin.Int)` methods. Note these methods are order dependent as the smaller `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minWidthDp()` and `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minHeightDp()` would match all the breakpoints that are larger. Therefore when processing the selection should normally be ordered from larger to smaller breakpoints.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowWidthSizeClass` |   |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowHeightSizeClass` |   |

## Summary

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#HEIGHT_DP_EXPANDED_LOWER_BOUND() = 900` A lower bound for a size class with Expanded height in dp. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#HEIGHT_DP_MEDIUM_LOWER_BOUND() = 480` A lower bound for a size class with Medium height in dp. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WIDTH_DP_EXPANDED_LOWER_BOUND() = 840` A lower bound for a size class with Expanded width in dp. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WIDTH_DP_EXTRA_LARGE_LOWER_BOUND() = 1600` A lower bound for a size class width Extra Large width in dp. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WIDTH_DP_LARGE_LOWER_BOUND() = 1200` A lower bound for a size class with Large width in dp. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WIDTH_DP_MEDIUM_LOWER_BOUND() = 600` A lower bound for a size class with Medium width in dp. | Cmn |

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` | `[compute](https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#compute(kotlin.Float,kotlin.Float))(dpWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, dpHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` **This function is deprecated.** Use computeWindowSizeClass instead. | Cmn |

| ### Public companion properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#BREAKPOINTS_V1()` The recommended breakpoints for window size classes. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#BREAKPOINTS_V2()` The recommended breakpoints for window size classes. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WindowSizeClass(kotlin.Int,kotlin.Int)(minWidthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, minHeightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#WindowSizeClass(kotlin.Float,kotlin.Float)(widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` A convenience constructor that will truncate to ints. | Cmn |

| ### Public functions |
|---|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#hashCode()()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isAtLeastBreakpoint(kotlin.Int,kotlin.Int)(widthDpBreakpoint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, heightDpBreakpoint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns `true` when `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minWidthDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isAtLeastBreakpoint(kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minHeightDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isAtLeastBreakpoint(kotlin.Int,kotlin.Int)`, `false` otherwise. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isHeightAtLeastBreakpoint(kotlin.Int)(heightDpBreakpoint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns `true` when `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minHeightDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isHeightAtLeastBreakpoint(kotlin.Int)`, `false` otherwise. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isWidthAtLeastBreakpoint(kotlin.Int)(widthDpBreakpoint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns `true` when `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minWidthDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isWidthAtLeastBreakpoint(kotlin.Int)`, `false` otherwise. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minHeightDp()` Returns the lower bound for the height of the size class in dp. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minWidthDp()` Returns the lower bound for the width of the size class in dp. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowHeightSizeClass` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#windowHeightSizeClass()` **This property is deprecated.** Use either isHeightAtLeastBreakpoint or isAtLeastBreakpoint to check matching bounds. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowWidthSizeClass` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#windowWidthSizeClass()` **This property is deprecated.** Use either isWidthAtLeastBreakpoint or isAtLeastBreakpoint to check matching bounds. | Cmn |

## Constants

### HEIGHT_DP_EXPANDED_LOWER_BOUND

Cmn

```
const val HEIGHT_DP_EXPANDED_LOWER_BOUND = 900: Int
```

A lower bound for a size class with Expanded height in dp.

### HEIGHT_DP_MEDIUM_LOWER_BOUND

Cmn

```
const val HEIGHT_DP_MEDIUM_LOWER_BOUND = 480: Int
```

A lower bound for a size class with Medium height in dp.

### WIDTH_DP_EXPANDED_LOWER_BOUND

Cmn

```
const val WIDTH_DP_EXPANDED_LOWER_BOUND = 840: Int
```

A lower bound for a size class with Expanded width in dp.

### WIDTH_DP_EXTRA_LARGE_LOWER_BOUND

Cmn

```
const val WIDTH_DP_EXTRA_LARGE_LOWER_BOUND = 1600: Int
```

A lower bound for a size class width Extra Large width in dp.

### WIDTH_DP_LARGE_LOWER_BOUND

Cmn

```
const val WIDTH_DP_LARGE_LOWER_BOUND = 1200: Int
```

A lower bound for a size class with Large width in dp.

### WIDTH_DP_MEDIUM_LOWER_BOUND

Cmn

```
const val WIDTH_DP_MEDIUM_LOWER_BOUND = 600: Int
```

A lower bound for a size class with Medium width in dp.

## Public companion functions

### compute

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/window#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun [compute](https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#compute(kotlin.Float,kotlin.Float))(dpWidth: Float, dpHeight: Float): WindowSizeClass
```

> [!CAUTION]
> **This function is deprecated.**   
> Use computeWindowSizeClass instead, use this instead:
>
> ```kotlin
> BREAKPOINTS_V1.computeWindowSizeClass(widthDp = dpWidth, heightDp = dpHeight)
> ```

Computes the recommended `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` for the given width and height in DP.

| Parameters |
|---|---|
| `dpWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | width of a window in DP. |
| `dpHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | height of a window in DP. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is recommended for the given dimensions. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass.Companion#compute(kotlin.Float,kotlin.Float)` or `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass.Companion#compute(kotlin.Float,kotlin.Float)` is negative. |

## Public companion properties

### BREAKPOINTS_V1

Cmn

```
val BREAKPOINTS_V1: Set<WindowSizeClass>
```

The recommended breakpoints for window size classes.

```kotlin
import androidx.window.core.layout.WindowSizeClass
import androidx.window.core.layout.computeWindowSizeClass

return WindowSizeClass.BREAKPOINTS_V1.computeWindowSizeClass(widthDp, heightDp)
```

### BREAKPOINTS_V2

Cmn

```
val BREAKPOINTS_V2: Set<WindowSizeClass>
```

The recommended breakpoints for window size classes. This includes all the breakpoints from `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#BREAKPOINTS_V1()` plus new breakpoints to account for the Large and Extra Large width breakpoints.

```kotlin
import androidx.window.core.layout.WindowSizeClass
import androidx.window.core.layout.computeWindowSizeClass

return WindowSizeClass.BREAKPOINTS_V1.computeWindowSizeClass(widthDp, heightDp)
```

## Public constructors

### WindowSizeClass

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
WindowSizeClass(minWidthDp: Int, minHeightDp: Int)
```

### WindowSizeClass

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
WindowSizeClass(widthDp: Float, heightDp: Float)
```

A convenience constructor that will truncate to ints.

## Public functions

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### isAtLeastBreakpoint

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun isAtLeastBreakpoint(widthDpBreakpoint: Int, heightDpBreakpoint: Int): Boolean
```

Returns `true` when `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minWidthDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isAtLeastBreakpoint(kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minHeightDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isAtLeastBreakpoint(kotlin.Int,kotlin.Int)`, `false` otherwise. When processing a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` note that this method is order dependent. Selection should go from largest to smallest breakpoints.

### isHeightAtLeastBreakpoint

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun isHeightAtLeastBreakpoint(heightDpBreakpoint: Int): Boolean
```

Returns `true` when `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minHeightDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isHeightAtLeastBreakpoint(kotlin.Int)`, `false` otherwise. When processing a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` note that this method is order dependent. Selection should go from largest to smallest breakpoints.

### isWidthAtLeastBreakpoint

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun isWidthAtLeastBreakpoint(widthDpBreakpoint: Int): Boolean
```

Returns `true` when `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#minWidthDp()` is greater than or equal to `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass#isWidthAtLeastBreakpoint(kotlin.Int)`, `false` otherwise. When processing a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` note that this method is order dependent. Selection should go from largest to smallest breakpoints.

```kotlin
import androidx.window.core.layout.WindowSizeClass.Companion.WIDTH_DP_EXPANDED_LOWER_BOUND
import androidx.window.core.layout.WindowSizeClass.Companion.WIDTH_DP_MEDIUM_LOWER_BOUND

return when {
    sizeClass.isWidthAtLeastBreakpoint(WIDTH_DP_EXPANDED_LOWER_BOUND) -> {
        // return UI for EXPANDED width size class
        FakeUiValues.EXPANDED
    }
    sizeClass.isWidthAtLeastBreakpoint(WIDTH_DP_MEDIUM_LOWER_BOUND) -> {
        // return UI for MEDIUM width size class
        FakeUiValues.MEDIUM
    }
    else -> {
        // return UI for COMPACT width size class
        FakeUiValues.COMPACT
    }
}
```

### toString

Cmn

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

## Public properties

### minHeightDp

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
val minHeightDp: Int
```

Returns the lower bound for the height of the size class in dp.

### minWidthDp

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
val minWidthDp: Int
```

Returns the lower bound for the width of the size class in dp.

### windowHeightSizeClass

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/window#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
val windowHeightSizeClass: WindowHeightSizeClass
```

> [!CAUTION]
> **This property is deprecated.**   
> Use either isHeightAtLeastBreakpoint or isAtLeastBreakpoint to check matching bounds.

Returns the `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowHeightSizeClass` that corresponds to the heightDp of the window.

### windowWidthSizeClass

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/window#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
val windowWidthSizeClass: WindowWidthSizeClass
```

> [!CAUTION]
> **This property is deprecated.**   
> Use either isWidthAtLeastBreakpoint or isAtLeastBreakpoint to check matching bounds.

Returns the `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowWidthSizeClass` that corresponds to the widthDp of the window.