Variable scope (global vs local) in Sass
📖 Scenario: You are creating a simple stylesheet for a website. You want to use Sass variables to control colors. You will learn how variables behave inside and outside of Sass blocks like @mixin and @function.
🎯 Goal: Build a Sass file that shows how global and local variables work by defining a global color variable, changing it locally inside a mixin, and using both values in styles.
📋 What You'll Learn
Create a global variable
$main-color with the value #3498dbCreate a variable
$local-color inside a mixin with the value #e74c3cUse
!global to change the global $main-color inside the mixinApply styles to a class
.box using the global $main-colorApply styles to a class
.alert using the local $local-color inside the mixin💡 Why This Matters
🌍 Real World
Using variables in Sass helps keep colors and styles consistent and easy to update across a website.
💼 Career
Understanding variable scope in Sass is important for front-end developers working with CSS preprocessors to write maintainable and scalable stylesheets.
Progress0 / 4 steps