---
title: "WindowInsets"
description: "A [DeviceConfigurationOverride] that overrides the window insets for the contained content."
type: "function"
---

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


<a id='references'></a>
<div class='sourceset sourceset-android'>Android</div>


```kotlin
fun DeviceConfigurationOverride.Companion.WindowInsets(
    windowInsets: WindowInsetsCompat
): DeviceConfigurationOverride
```


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

#### Parameters

| | |
| --- | --- |
| windowInsets | the `WindowInsetsCompat` to render the content under test in. |


#### Returns

| | |
| --- | --- |
|  | a `DeviceConfigurationOverride` that specifies the window insets for the content under test. |




## Code Examples
### DeviceConfigurationOverrideWindowInsetsSample
```kotlin
@Composable
fun DeviceConfigurationOverrideWindowInsetsSample() {
    fun IntRect.toAndroidXInsets() = androidx.core.graphics.Insets.of(left, top, right, bottom)
    DeviceConfigurationOverride(
        DeviceConfigurationOverride.WindowInsets(
            WindowInsetsCompat.Builder()
                .setInsets(
                    WindowInsetsCompat.Type.captionBar(),
                    with(LocalDensity.current) { DpRect(0.dp, 64.dp, 0.dp, 0.dp).toRect() }
                        .roundToIntRect()
                        .toAndroidXInsets(),
                )
                .setInsets(
                    WindowInsetsCompat.Type.navigationBars(),
                    with(LocalDensity.current) { DpRect(24.dp, 0.dp, 48.dp, 24.dp).toRect() }
                        .roundToIntRect()
                        .toAndroidXInsets(),
                )
                .build()
        )
    ) {
        Box(
            Modifier.background(Color.Blue)
                // Will apply 64dp padding on the top, 24dp padding on the sides, and 48dp on the
                // bottom
                .safeDrawingPadding()
                .background(Color.Red)
        )
    }
}
```

