Hacker News new | past | comments | ask | show | jobs | submit login

Do you have an article that explains this approach in just a little more detail?




See https://developer.mozilla.org/en-US/docs/Web/CSS/:root#decla....

With :root, you can write css variables that can be accessed by any other element on the page (?).

So to implement a light and dark theme, you could have something like `@media (prefers-color-scheme: light){ :root { --bg-color: #FFF; }`, and then have the body element use that via `body { background: var(--bg-color); }`.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: