Change Colour Themes Programmatically

Is there any way to change the colour themes at run time?

I would like to offer a light/dark theme for one of my apps as a user setting, and in the material design I see placeholders that get substituted in the CSS file (eg: %color:Gray 900%)

I appreciate I could delve into JS to do this, but is there a built in way?