is there an option to control the button theme in ...
# compose
t
is there an option to control the button theme in compose? i mean like customize it on the theme level so that every material button under that theme inherits thoes properties
z
You mean besides customizing the MaterialTheme itself?
t
what im looking for is giving Buttons a specific color, corner radius...etc that only applies to Buttons but not other material components
the closest example is what i tried with flutter like this, there is a theme data object that you can pass to the theme for each component
Copy code
ThemeData(
useMaterial3: true,
canvasColor: colorScheme.surface,
outlinedButtonTheme: myOutlinedButtonTheme(),
filledButtonTheme: myFilledButtonTheme(),
);

FilledButtonThemeData myFilledButtonTheme() {
  return FilledButtonThemeData(
    style: FilledButton.styleFrom(
      minimumSize: Size(0, 52),
      textStyle: TextStyles.button.copyWith(fontWeight: FontWeight.w700),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(10),
      ),
    ),
  );
}
s
I don't think there's a way to do that. You'd have to create your own button composable that wraps the original, and create a composition local that provides the buttons' theming options. And ofc replace all existing usages of the material button with your own.
👍 1
s
With such levels of customizability I'd say you're probably better off making your own component completely, and not relying on m3 in the first place
2
s
That's a good idea, but his customizations are rather conservative, so he can do just fine with wrapping & modifying the existing stuff. That's of course if he wants his app to conform to Material Design as closely as possible, otherwise custom components are the way to go.
t
@Stylianos Gakis i don't think thats worth it just for changing the corner radius and maybe the color, but yeah creating my own component on top of the existing one seems like a good solution
👍 1