Property

LocalContentAlpha

CompositionLocal containing the preferred content alpha for a given position in the hierarchy.

ContentAlphaSample

@Sampled
@Composable
fun ContentAlphaSample() {
    // Note the alpha values listed below are the values for light theme. The values are slightly
    // different in dark theme to provide proper contrast against the background.
    Column {
        Text(
            "No content alpha applied - uses the default content alpha set by MaterialTheme - " +
                "87% alpha"
        )
        CompositionLocalProvider(LocalContentAlpha provides 1.00f) {
            Text("1.00f alpha applied - 100% alpha")
        }
        CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.high) {
            Text("High content alpha applied - 87% alpha")
        }
        CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
            Text("Medium content alpha applied - 60% alpha")
        }
        CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) {
            Text("Disabled content alpha applied - 38% alpha")
        }
    }
}
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: