Property

LocalAbsoluteElevation

CompositionLocal containing the current absolute elevation provided by Surface components.

AbsoluteElevationSample

@Suppress("UNUSED_VARIABLE", "NAME_SHADOWING")
@Sampled
@Composable
fun AbsoluteElevationSample() {
    Surface(elevation = 4.dp) {
        // This will equal 4.dp
        val elevation = LocalAbsoluteElevation.current
        Surface(elevation = 2.dp) {
            // This will equal 6.dp (4 + 2)
            val elevation = LocalAbsoluteElevation.current
        }
    }
}
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: