Dynamically adding a new css file to an application

Hello all,

We have defined a theme for our application, but we want to give our users the possibility to have some colors in the application to be overridden.

For example let’s say we define a button to have a standard red color. Now the user wants that button to be green.

What we came up with is that a user can have a custom css file (a slimmed down version of the main one) with some overridden styles.

This would mean that we always include the main styles.css file and then, depending on which user is using the application, a custom one that contains the overridden styles.

The custom css would not be part of the Web application (so, not in the theme folder), but would reside somewhere else. So, the setTheme() method would not pick up this custom css.

Basically I imagine the code to be something like this :

    app.setTheme("main");
    app.addCustomCssFile("someLocation/username.css")

Does something like this exist or does anyone have another or a better idea to this?

Thanks in advance.

Well, you can provide dynamically generated files with an
URIHandler
. However, that probably wouldn’t be a very good idea, because CSS files are loaded just once, which would make such a solution rather static anyhow.

The
CSSInject add-on
might do want you want.

Also the CssLayout and CellStyleGenerator in Table give some special possibilities for dynamic styling.