Hi, how can I force the color of the text in a `@C...
# compose-desktop
a
Hi, how can I force the color of the text in a
@Composable
function (with a
content: @Composable () -> Unit
argument) like in the
Button
Composable ?
b
Wrap its invocation in sub Material theme and override relevant props? Just a thought...
c
Text in the Material UI is displayed with color from
LocalContentColor
, and more generally is fully styled via
LocalTextStyle
. Providing new compositionLocals for those allows parents to style the text of their Children.
ProvideTextStyle() { }
is a helpful shortcut for applying new styles for children
Text()
composables like this
2
c
Yep, this is how Button is implemented:
That is, you would wrap your content block with
ProvideTextStyle
and pass whatever TextStyle you want to
value
(replace MaterialTheme.typography.button in the example above)