Last weekend I attended BarCampGR for the first time. This was the first time I had been to an “un-conference” and that idea hit me right away when my nametag said “Speaker.” Well, so did everyone else’s nametags. All Friday night I kept thinking about what I could represent that would be of interest to the attendees. Then it hit me: SASS. I gave a small talk on SASS on Saturday, hailing four benefits that make using SASS worthwhile. I’ll describe them briefly in this blog post.
Variables
The first benefit of SASS is the existence of variables. This alone makes learning and using SASS worthwhile. No more find and replace commands across project folders. Setup variables for colors, units, or any kind of string, and only ever have to change it in one spot.
Nested rules
If variables weren’t enough to convince you to use SASS, nested rules should put you over the edge. No more having to repeat previous selectors to get a more specific CSS rule. Simply place the next rule inside the previous one’s curly brackets, and it instantly turns it into a more specific rule.
Mixins (Functions)
Functions are used is every programming language because, well, duh! CSS is not a programming language so it does not have all the benefits of functions. SASS comes along, though, and offers function-like entities called mixins, which let you modularize and recycle code with a single line.
Loops
Like mixins, SASS extends another programming idea to CSS – loops. In SASS you can setup the equivalent of a multi-dimensional array and loop through it, generating CSS that would have otherwise been very repetitive.
What other benefits have you seen in using SASS? Any negatives?
Need a fresh perspective on a tough project?
Let’s talk about how RDG can help.