Compose Modifier

safeContentPadding

Adds padding to accommodate the safe content insets.

safeContentPaddingSample

@Sampled
fun safeContentPaddingSample() {
    class SampleActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            WindowCompat.setDecorFitsSystemWindows(window, false)
            super.onCreate(savedInstanceState)
            setContent {
                Box(Modifier.background(Color.Black).systemBarsPadding()) {
                    // The app content will only be drawn where there is no possible
                    // gesture confusion and content will not be drawn over.
                    // The rest will be plain white
                    Box(Modifier.background(Color.White).safeContentPadding()) {
                        // app content
                    }
                }
            }
        }
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: