---
title: "MutableWindowInsets"
description: "A [WindowInsets] whose values can change without changing the instance. This is useful to avoid
recomposition when [WindowInsets] can change.


Note: This API as experimental since it doesn't enforce the right consumption patterns."
type: "class"
---

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


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
@ExperimentalLayoutApi
class MutableWindowInsets(initialInsets: WindowInsets = WindowInsets(0, 0, 0, 0)) : WindowInsets
```


A `WindowInsets` whose values can change without changing the instance. This is useful to avoid
recomposition when `WindowInsets` can change.


Note: This API as experimental since it doesn't enforce the right consumption patterns.


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
var insets
```


The `WindowInsets` that are used for `left`, `top`, `right`, and
`bottom` values.




## Code Examples

### withConsumedInsetsSample
```kotlin
@OptIn(ExperimentalLayoutApi::class)
fun withConsumedInsetsSample() {
    class SampleActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            WindowCompat.setDecorFitsSystemWindows(window, false)
            super.onCreate(savedInstanceState)
            setContent {
                val remainingInsets = remember { MutableWindowInsets() }
                val safeContent = WindowInsets.safeContent
                Box(
                    Modifier.navigationBarsPadding().onConsumedWindowInsetsChanged {
                        consumedWindowInsets ->
                        remainingInsets.insets = safeContent.exclude(consumedWindowInsets)
                    }
                ) {
                    // padding can be used without recomposition when insets change.
                    val padding = remainingInsets.asPaddingValues()
                    Box(Modifier.padding(padding))
                }
            }
        }
    }
}
```

