JSFiddle - React, Tailwind, and code Playground
HTML
<div class="themed">
Your theme is:
</div>
CSS
:root {
/* light */
--theme-light-background: #fff;
--theme-light-color: #000;
/* dark */
--theme-dark-background: #000;
--theme-dark-color: #fff;
}
.themed {
background-color: var(--background);
color: var(--color);
}
.themed::after {
content: "not found";
}
@media (prefers-color-scheme: light) {
.themed {
--background: var(--theme-light-background);
--color: var(--theme-light-color);
}
.themed::after {
content: "Light";
}
}
@media (prefers-color-scheme: dark) {
.themed {
--background: var(--theme-dark-background);
--color: var(--theme-dark-color);
}
.themed::after {
content: "Dark";
}
}