Hi, is this behavior intended in Material? Why is ...
# compose
k
Hi, is this behavior intended in Material? Why is it inconsistent?
Copy code
MaterialTheme {
    CompositionLocalProvider(
        LocalContentAlpha provides ContentAlpha.high
    ) {
        Surface(color = MaterialTheme.colors.primary) {
            LocalContentAlpha.current // 0.87 (LowContrastAlpha)
            ContentAlpha.high // 1.0 (HighContrastAlpha)
        }
    }
}
a
I guess Surface does it's own
Copy code
CompositionLocalProvider(
   LocalContentAlpha provides ...
)
k
No, Surface doesn't provide a new
LocalContentAlpha
. What happens here is that: • The ContentAlpha.high is recalculated, and because of the content color is light on light theme, it provides high contrast alpha. • LocalContentAlpha uses previously calculated alpha when the content color is dark on light theme, it uses low contrast alpha.