New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Compose Foundation Layout

windowInsetsPadding

Common

Adds padding so that the content doesn't enter [insets] space.

Any insets consumed by other insets padding modifiers or [consumeWindowInsets] on a parent layout will be excluded from [insets]. [insets] will be [consumed][consumeWindowInsets] for child layouts as well.

For example, if an ancestor uses [statusBarsPadding] and this modifier uses [WindowInsets.Companion.systemBars], the portion of the system bars that the status bars uses will not be padded again by this modifier.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.foundation:foundation-layout:1.7.0-beta04")
}

Overloads

@Stable
fun Modifier.windowInsetsPadding(insets: WindowInsets)

Code Example

insetsPaddingSample

@Sampled
fun insetsPaddingSample() {
    class SampleActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            WindowCompat.setDecorFitsSystemWindows(window, false)
            super.onCreate(savedInstanceState)
            setContent {
                val insets = WindowInsets.systemBars.union(WindowInsets.ime)
                Box(
                    Modifier
                        .background(Color.White)
                        .fillMaxSize()
                        .windowInsetsPadding(insets)) {
                    // app content
                }
            }
        }
    }
}