Updating/Dynamic App Theme at Runtime

I have an app that I want to deliver to a number of different clients, I want to be able to theme the app differently for each client. I know there is a way to update CSS dynamically, but each client’s theme might edit different components in different ways depending on requirements. A client would probably be given a different URL/login for the app, so I want to be able to pull the required modified colours from somewhere when a client first opens the app

You can use the CSS injection from anvil extras (yes I know it has an _ at the beginning so it’s meant to be a private class… but, it’s worked for a loong time, so shouldn’t be a problem).

I stored the dynamic CSS in a data table, but you could store it in modules or files or files in the data tables.

If it’s just colours you want to change, Anvil Extras has a module for that:

It seems we failed to include a link to its documentation on our main docs site but here’s the source doc:

3 Likes

Ya know, it’s a funny thing, I saw that in autocomplete earlier and had no idea what it was for, haha.

Docs now fixed:

https://anvil-extras.readthedocs.io/en/latest/guides/modules/theme.html

3 Likes

This is great thank you. Already use extras fairly extensively so this should be an easy addition

1 Like