How to change theme on the fly?

The hamburger theme selector now has an option to change the theme CSS ‘on-the-fly’, and then trigger a reload on the next page navigation.

https://github.com/discourse/discourse-hamburger-theme-selector/commit/8e20b1cc9a958955845deaf44ed1e6a389c9d7ed

I’ve put this behind a setting, and toggled it on Meta so you can try it out. Would you like me to make it default @sam?

@ggurbet to answer your Development question directly, you can change the theme immediately by using

var themeSelector = require('discourse/lib/theme-selector');
themeSelector.previewTheme([themeId]);

That will set the CSS on the current page, but will not save the setting. If you want it to persist across navigations you also need

themeSelector.setLocalTheme([themeId], seq);

Check the code for the hamburger theme selector to see how to obtain a value for seq - you need to make sure not to cause an error for anonymous users (set the seq to 0 in that case).