windowInsetsBottomHeight

Compose Modifier

Common
fun Modifier.windowInsetsBottomHeight(insets: WindowInsets) =
    this.then(
        DerivedHeightModifier(
            insets,
            debugInspectorInfo {
                name = "insetsBottomHeight"
                properties["insets"] = insets
            },
            bottomCalc,
        )
    )

Sets the height to that of insets at the bottom of the screen.

When used, the WindowInsets will respect the consumed insets from windowInsetsPadding and consumeWindowInsets, but won't consume any insets.

Code Examples

insetsBottomHeightSample

fun insetsBottomHeightSample() {
    class SampleActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            WindowCompat.setDecorFitsSystemWindows(window, false)
            super.onCreate(savedInstanceState)
            setContent {
                Box(Modifier.fillMaxSize()) {
                    // Background for navigation bar at the bottom
                    Box(
                        Modifier.windowInsetsTopHeight(WindowInsets.navigationBars)
                            .fillMaxWidth()
                            .align(Alignment.BottomCenter)
                            .background(Color.Red)
                    )
                    // app content
                }
            }
        }
    }
}