<@UK5SVA94Z>, May I ask a question. I have a requi...
# android
a
@nickbutcher, May I ask a question. I have a requirement where the buttons in my app doesn't match the Theme's Primary Color... In current theming we do a way with this by setting a theme overlay on our button theme and setting it in styles so all button gets the set color like:
Copy code
<style name="MyTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        ...
        <item name="materialButtonStyle">@style/Widget.MyButton</item>
        <item name="materialButtonOutlinedStyle">@style/Widget.MyButton.Outlined</item>
        ...
</style>

<!--Buttons Styles-->
<style name="ThemeOverlay.MyButton" parent="">
        ...
        <item name="colorPrimary">@color/mycolor</item>
        <item name="colorOnPrimary">@color/myOnColor</item>
        ...
</style>

<style name="Widget.MyButton" parent="Widget.MaterialComponents.Button">
        <item name="materialThemeOverlay">@style/ThemeOverlay.MyButton</item>
        ...
</style>

....
But in
Jetpack Compose
there is no
styles
to set. Is it correct to instead of using the
Button
directly, simply create a "`MyButton` " and use it instead like:
Copy code
@Composable
fun MyButton(
    ....
    modifier = Modifier,
) {
   Button(modifier = modifier.backgroundColor(myColor)
        ....
}
or is there a better and correct way to do this?
n
Yes create your own composable. I'd set the `Button`s color using the param rather than a modifier but right general idea. https://developer.android.com/jetpack/compose/themes#component-styles
a
Wow! I didn't know there's documentation for this. Thank you very much!
👍 1
i
Also note that this is a better question for #compose
a
@Ian Lake, ah yes. I'm sorry about that, I actually thought I was in the compose channel when typing all these out. Will not happen again.