3 ms·
Is there no JS APIs to use those either? Cause that would make it infinitely cooler imho, then you can surface it as a way to show off web app themes on the fro
by giancarlostoro 5y ago
Is there no JS APIs to use those either? Cause that would make it infinitely cooler imho, then you can surface it as a way to show off web app themes on the front-end too.
- iggldiggl 5y agoNothing pre-built, but you can cobble something together yourself – query the DOM for stylesheets, evaluate their attributes (i.e. especially the "title" and "alternate" attributes) and then enable and disable them as required. I wrote something like that for my homepage, although as I only needed to switch between two styles and I'm not a front-end person, I didn't bother with an actual selection drop-down and just wrote a toggle that cycles through all alternate stylesheets one at a time.
- toastal 5y agoThis works pretty nicely if they only refer to which CSS variables to load and the main CSS file is waiting to be overridden by these variables. I just wish it got a higher priority by browsers to have good built-ins.