Integration with the new media query: prefers-color-scheme #1022
-
What is it The incoming media query @media (prefers-color-scheme: dark) {
div {
color: white;
background: black;
}
}
@media (prefers-color-scheme: light) {
div {
color: black;
background: white;
}
} What should we do Maybe a solution, tutorial about how to adapt two different Fomantic-UI themes with the Similar discussion 【twbs/bootstrap】Support for prefers-color-scheme media query |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Since we have the new Central dynamic color map, it's possible to add the color variables for the dark theme. @pinkiepie: {
color : @pinkie;
+ darkColor : @darkPinkie;
light : @lightPinkie;
+ darkLight : @darkPinkie;
background : @lightPinkie;
+ darkBackground: @darkPinkie;
...
}; But it's stupid since you will have to render the styles twice now for the different color scheme. @media (prefers-color-scheme: light) {
.ui.pinkiepie.button {
color : @color;
background: @background;
}
}
@media (prefers-color-scheme: dark) {
.ui.pinkiepie.button {
color : @darkColor;
background: @darkBackground;
}
} Solution The solution will be the CSS Variable. Where we only need to define the style once and change the variable only between the different preferred color scheme. /**
* Variables
*/
@media (prefers-color-scheme: light) {
:root {
--pinkepieColor : @color;
--pinkepieBackground: @background;
}
}
@media (prefers-color-scheme: dark) {
:root {
--pinkepieColor : @darkColor;
--pinkepieBackground: @darkBackground;
}
}
/**
* Definition
*/
.ui.pinkiepie.button {
color : var(--pinkepieColor);
background: var(--pinkepieBackground);
} |
Beta Was this translation helpful? Give feedback.
-
I think, you can achieve this today without any change to the code and keep full IE11 compatibility. @import url('semantic.css'); /*default for non supporting browsers */
@import url('semantic-my-custom-dark-theme.css') (prefers-color-scheme: dark);
@import url('semantic-my-custom-light-theme.css') (prefers-color-scheme: light); |
Beta Was this translation helpful? Give feedback.
-
I am closing this, because i think my simple suggested solution is sufficient |
Beta Was this translation helpful? Give feedback.
I think, you can achieve this today without any change to the code and keep full IE11 compatibility.