How do I introduce theming with CSS variables?
I am building an NPM package that is supposed to have basic values, which are defined like
:root { --primary: red; }
when I import those values and afterwards declare
:root { --primary: blue; }
for some variables there is a change, for some, not. I thought I might take advantage of DOM precedence like
:root > * { --primary: blue; }
but then none of the theme styles get applied. I assume because my dependant styles like this are also declared on root level in the npm package:
:root { --header-primary: var(--primary); }
So how do you do it the right way?