Kevin Powell - CommunityKP-C
Kevin Powell - Communityโ€ข2y agoโ€ข
6 replies
zobweyt

Using CSS selectors with @media queries

Hey! I want user to select between dark, light, and system themes (and maybe even third, fourth, etc).

I came up with this pen in mind: https://codepen.io/zobweyt/pen/BagdyGq

But it's not working as expected. I want to turn on dark styles when any of the following conditions satisfy:
- There's [data-theme="dark"] on an element
- There's [data-theme="system"] on an element with @media (prefers-color-scheme: dark)

I can't find a solution to make it without copy-pasting and mixins from SCSS or PostCSS, etc

Is it even possible?
CodePenzobweyt
...
BagdyGq
Was this page helpful?