yarn add css-variable-theme
import { registerThemes } from 'css-variable-theme';
registerThemes({
// light theme and its css variables
light: {
"--bg": "#fff",
"--color": "#333"
},
dark: {
"--bg": "#555",
"--color": "#eee"
}
});
xxx.css
.demo {
background: var(--bg);
color: var(--color);
}
another.js
import { setTheme } from 'css-variable-theme';
setTheme('light');