I couldn’t find where this existed already, so I created it! Some simple code you can use in your apps to dynamically/programmatically change the color scheme from among the built-in ones. Anvil | Login
You can easily add your own color schemes to the file as well. I hope this helps someone!
5 Likes
Worth linking this thread too:
@EsbenLorenzen the current way to do this doesn’t need to involve fancy css, instead you might take the Material Light and Material Dark theme color schemes.
Open the app in one color scheme, log the output of app.theme_colors and repeat with the other color scheme.
>>> app.theme_colors
ThemeColors({'Secondary Container': '#E8DEF8', 'Tertiary Container': '#FFD8E4', 'On Background': '#1C1B1F', 'Disabled Container': 'rgba(28, 27, 31, 0.12)', 'On Tertiary': '#FFFFFF', 'Outline': '#79747E', 'On Pr…
thanks very much for this. very handy!
1 Like
This works very nicely. Thank you.
However…
The docs say that app.theme_colors
is a read only dict.
Is the fact that using it to set colours works something we can rely on?
Yes - we added write support but looks like we didn’t update the api docs.
When it was read only, using theme colors in this way would have raised an exception.
3 Likes
Excellent! That’s exactly the answer I was hoping for!
1 Like