DEV Community

Discussion on: STOP writing CSS, 10 reasons why

Collapse
 
gsarig profile image
Giorgos Sarigiannidis • Edited

Actually, I believe that CSS variables are better than SASS's, for two main reasons:

  1. They can be modified from within media queries. For example, you write some css which use a specific value stored in a variable and then, on the media query, you don't need to repeat the same code if all you need is a few calculations based on a different value. You can just declare the variable again, with the new value.
  2. They can be manipulated with JavaScript, which is a big thing.

Personally, I like SASS and I use it all the time, but I've started using native variables for the aforementioned reason.

Here is a small pen that demonstrates how those two can work together and how easy it is to manipulate them with JS (and a more detailed explanation here).

Collapse
 
aspiiire profile image
Aspiiire

Thanks for sharing you knowledge Giorgos, I totally agree, I didn't know about the root thing... and thanks for the article :)

Collapse
 
shadowtime2000 profile image
shadowtime2000

Yeah, I agree they are better than SASS variables. I am also pretty sure that some CSS frameworks are using CSS variables to allow you to customize the theme colors which is a bonus when you don't want to style stuff but you want to dynamically change the theme colors.