Overview - Variable scope (global vs local)
What is it?
Variable scope in Sass means where a variable can be used in your styles. Global variables are available everywhere in your Sass files, while local variables only exist inside a specific block like a function or mixin. This helps keep your styles organized and prevents accidental changes. Understanding scope helps you control which parts of your code can see or change a variable.
Why it matters
Without variable scope, all variables would be visible everywhere, causing conflicts and bugs when different parts of your styles accidentally change the same variable. This would make your styles hard to maintain and debug. Scope lets you protect variables and write cleaner, safer code that grows well as your project gets bigger.
Where it fits
Before learning variable scope, you should know how to create and use variables in Sass. After mastering scope, you can learn about functions, mixins, and how to organize large Sass projects with partials and imports.