Hi everybody !
I’m currently discovering themes in Jetpack Compose for Android. I would like to have the opinion of people who worked a bit on the topic. I feel themes are especially made to implement material design. Obviously, I now you can add custom colors to your theme to implement your own design system but what do I gain compared to just putting my ressources in data classes and calling them without using themes ?
1 year ago
Hi I read your question few times and still I do not get it. Can you give us simple example? 🙂
In theme you can override colors like: primary, secondary, onSurface, etc. Are you asking about additional colors in theme?
1 year ago
Hi Piotr 🙂 Sorry if that was not very clear. I have a design system which doesn't use the nine default colors of the material theme at all. I know I can add more colors to the theme instead of overriding it to solve this problem but I don't see the point of using Compose themes in this case... I could simply build a "simpler" theme logic myself...
ok, what I can say is that I am using also few colors that do not suit to material design system.
What can be challenging in your case is that some compose components calculate surface, background or other colors base on your main color. If your design system is completely custom, those components will be tricky to use or even impossible, so you will need to make your own custom components that are more flexible in therms of secondary colors etc.
quick example: TextField. This component has variable named:
of type TextFieldColors. This data class has 8 different variables to define colors. You will probably change all of them 🙂
Zach Klippenstein (he/him) [MOD]
1 year ago
Compose UI doesn’t have any design-system-agnostic theming support, specifically. The compose Material library includes theming infrastructure for Material, but if you’re not using Material as your design system then you can build whatever theming abstractions make sense for your system (eg providing data classes through some composition locals). That’s by design.