I’m building an app that lets the user select any ...
# compose
j
I’m building an app that lets the user select any arbitrary color. I then want to take that color and theme some components off of it. Is there a way in Compose to take a color and generate a theme? Or even some lighter/darker versions of it?
s
Also maybe this? https://github.com/Kyant0/m3color I think there must be something else too which I can't find atm
j
Thanks! I’ll give them a look 👍
In case anyone else comes across this thread, and wants to generate dynamic color schemes. I’ve turned material-color-utilites (which the above m3color is based on) into a Compose Multiplatform library: https://github.com/jordond/materialkolor
s
That’s pretty cool! Does this just generate a m3 colorScheme directly, or are the parts that just generate a palette exposed too? We use a mix of material3 colorScheme + some of our own tokens, so getting access to the underlying palette would be necessary to be able to adapt something like this fully. And I assume other people are doing the same too
j
It just uses this class from material-color-utilities to generate the color from the token which uses that libraries
DynamicColor.fromPalette()
. But I suppose there is nothing stopping you from using
DynamicColor.fromPalette()
yourself. If you had an example of the functionality you wanted, I could look into implementing it.