---
title: "WindowSize"
description: "A [DeviceConfigurationOverride] that overrides the window size for the contained content.

Like [ForcedSize], this is only suitable for tests, since this will override [LocalDensity] to
ensure that the [size] is met (as opposed to `Modifier.requiredSize` which will result in
clipping).

Unlike [ForcedSize], this override will override [LocalWindowInfo] and `LocalConfiguration` on
Android to reflect the requested size."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
expect fun DeviceConfigurationOverride.Companion.WindowSize(
    size: DpSize
): DeviceConfigurationOverride
```


A `DeviceConfigurationOverride` that overrides the window size for the contained content.

Like `ForcedSize`, this is only suitable for tests, since this will override `LocalDensity` to
ensure that the `size` is met (as opposed to `Modifier.requiredSize` which will result in
clipping).

Unlike `ForcedSize`, this override will override `LocalWindowInfo` and `LocalConfiguration` on
Android to reflect the requested size.

#### Parameters

| | |
| --- | --- |
| size | the `DpSize` to force the window size to appear as, changing density if necessary |


#### Returns

| | |
| --- | --- |
|  | a `DeviceConfigurationOverride` that forces the window size. |




<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual fun DeviceConfigurationOverride.Companion.WindowSize(
    size: DpSize
): DeviceConfigurationOverride
```


## Code Examples
### DeviceConfigurationOverrideWindowSizeSample
```kotlin
@Composable
fun DeviceConfigurationOverrideWindowSizeSample() {
    DeviceConfigurationOverride(DeviceConfigurationOverride.WindowSize(DpSize(1280.dp, 800.dp))) {
        MyScreen() // will be rendered with an apparent window size of 1280dp by 800dp without
        // clipping
    }
}
```

