SASS

Quick SASS tutorial with VS Code

Shelcia David
2 min readFeb 7, 2024

--

We will look into SASS on surface level to get you started.

Introduction

Welcome, code enthusiasts! Today, we’re diving into the exciting world of SASS with a quick and interactive tutorial using Visual Studio Code.

If you’ve ever felt overwhelmed by writing hundreds of lines in CSS, SASS might just be the solution you’re looking for.

Prerequisites

Before we embark on this SASS adventure, make sure you have the following:

  • Visual Studio Code (VS Code)
  • Basic knowledge of CSS

Why SASS?

Now, you might wonder, why should you bother with SASS? Well, if you’re tired of writing extensive CSS code and crave a more efficient way to style your web projects, SASS is the answer. It introduces features like variables, mixins, and modularity, making your stylesheets cleaner and more maintainable.

Setting Up

But before we start coding, let’s set up SASS in our project. Head over to sass-lang.com for detailed instructions. Don’t worry; it’s a breeze!

Install this extension on your VS code environment https://marketplace.visualstudio.com/items?itemName=ritwickdey.live-sass

Then click on “Watch my SASS” which would basically generate the compiled CSS based on SASS file whenever you make changes (super convenient).

Coding: Let the Fun Begin!

Now, let’s jump into the coding part. Open VS Code and follow along with the examples.

Variables

One of the coolest features of SASS is variables. They allow you to store information that you can reuse throughout your stylesheet. Let’s see it in action:

Here, we’ve defined a variable $primary-color and used it to set the background color of the body.

Mixins

Mixins are like reusable chunks of styles. They make your code more modular and DRY (Don’t Repeat Yourself). Check out this example:

The border-radius mixin makes it easy to apply rounded corners to elements without duplicating code.

Modularity

SASS allows you to break your styles into smaller, manageable parts. This enhances modularity and makes your codebase more organized. Here’s a sneak peek:

_buttons.scss
main.scss

By importing partials like _buttons.scss, you keep your styles neatly organized and maintainable.

Conclusion

And that’s a wrap! We’ve covered the basics of SASS, from setting it up to using variables, mixins, and modularity. Say goodbye to long, repetitive CSS files, and embrace the power of SASS in your projects.

Happy coding! 🚀

Bye !!

--

--

Shelcia David

MS in Information @ UW Madison || Ex Senior Software Developer @NASDAQ. I write articles about Web apps, UX and whatever I find interesting. www.shelcia-dev.me