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

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)."
type: "function"
---

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


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


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


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

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).

#### Parameters

| | |
| --- | --- |
| size | the `DpSize` to force the contained content to render in, changing density if necessary |


#### Returns

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




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


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


## Code Examples
### DeviceConfigurationOverrideForcedSizeSample
```kotlin
@Composable
fun DeviceConfigurationOverrideForcedSizeSample() {
    DeviceConfigurationOverride(DeviceConfigurationOverride.ForcedSize(DpSize(1280.dp, 800.dp))) {
        MyScreen() // will be rendered in the space for 1280dp by 800dp without clipping
    }
}
```

