Skip to content

Commit b03b52b

Browse files
committed
Update color mode mixin to support 'auto'
1 parent b89cac2 commit b03b52b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
// Allows CSS to be scoped to a specific color mode
22
@mixin color-mode($mode) {
33
@if $mode == light {
4-
:root,
4+
:root:not(data-color-mode),
55
[data-color-mode="light"] {
66
@content;
77
}
8+
9+
[data-color-mode="auto"] {
10+
@media (prefers-color-scheme: light) {
11+
@content;
12+
}
13+
}
814
}
915
@else if $mode == dark {
1016
[data-color-mode="dark"] {
1117
@content;
1218
}
19+
20+
[data-color-mode="auto"] {
21+
@media (prefers-color-scheme: dark) {
22+
@content;
23+
}
24+
}
1325
}
1426
}

0 commit comments

Comments
 (0)