Nacho_Caballero is having trouble with the dark-light-choose($light, $dark) function in their personalized CSS, always returning the $light value even when switching to a dark theme.
awesomerobot suggests that custom dark/light definitions need to be added to color_definitions.scss within a theme, and provides an example of how to define the colors and use them in other files.
Nacho_Caballero confirms that this solution works, but is unsure why variable interpolation is required when using CSS custom properties with color values.
pmusaraj explains that this is a SCSS requirement when using CSS custom properties, and points to the Sass documentation for more details.
I’m trying to use the dark-light-choose($light, $dark) function in my personalized CSS but it always returns $light even if I change the palette from light (Clara) to dark (Oscura):
I believe, due to the way the SCSS is compiled, custom dark/light definitions need to be added to color_definitions.scss within a theme and won’t work in other scss files.
color_definitions.scss is high up in the cascade (before a lot of the default styles), so you don’t want to add the .modal.history-modal ins part there. Instead you can just add the color definition itself…
Thank you so much, Kris. You saved me! It works perfectly
I’ve been playing around with it and the only thing I don’t understand is why variable interpolation is required with color values. For example, this doesn’t work without interpolation:
$ins: #7f7e7e;
:root {
--custom-ins: $ins;
}
But this does:
$ins: #7f7e7e;
:root {
--custom-ins: #{$ins};
}
Both versions work if $ins is assigned a variable (for example: $ins: $dark-theme-ins ).