Is there a way to change the values of a MaterialT...
# compose
a
Is there a way to change the values of a MaterialTheme TextStyle locally?
e.g.
Copy code
MaterialTheme.typography.button
will provide different values locally than globally. Kind of like
ProvideTextStyle
but only changing one specific MaterialTheme style. The UseCase is changing the textstyles for focused/unfocused label texts in an
OutlinedTextField
s
I don't know if it's a good idea but you can have a typography parameter in your AppTheme composable:
Copy code
@Composable
fun AppTheme(
    typography: Typography = DefaultTypography,
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable() () -> Unit
) {
    ...
    MaterialTheme(
        colors = colors,
        typography = typography,
        shapes = Shapes,
        content = content
    )
}
And then based on the focused or unfocused state of the text field you can pass a different typography:
Copy code
AppTheme(typography = if(focused) ... else ...) {
    TextField()
}