The true power of CSS variables lies is their dynamic nature – making them able to separate concerns (unlike static variables found in Sass, Less etc.)
// Static SCSS variables (maintainability)
$color-1: tomato;
$color-2: olive;
$color-3: gold;
// Dynamic CSS variables (separation of concerns)
// Note! needs interpolation to work with Sass
:root {
--body-color: $color-1;
@media (max-width: 960px){ --body-color: #{$color-3}; }
@media (max-width: 480px){ --body-color: #{$color-2}; }
}
// Implementation ("body-color-logic")
body { background-color: var(--body-color); }