Created
September 18, 2024 18:18
-
-
Save salazarr-js/e48a2fe8e3b2ad9121bceb2b11e75de7 to your computer and use it in GitHub Desktop.
Scss theme mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin theme($theme) { | |
@at-root #{selector-nest(':root[data-theme=#{$theme}]', &)} { | |
@content; | |
} | |
} | |
:root { | |
--bg-color: lightcoral; | |
} | |
body { | |
background-color: var(--bg-color); | |
color: #333; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
min-height: 100vh; | |
h1 { | |
@include theme(coder) { | |
color: red; | |
} | |
} | |
@include theme(dark) { | |
--bg-color: lightblue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment