0
0
SASSmarkup~5 mins

Default values with !default in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the !default flag do in Sass?
It sets a variable only if it has not been set before. This means the variable keeps its value unless it is undefined, then the !default value is used.
Click to reveal answer
beginner
How do you write a Sass variable with a default value of blue?
$color: blue !default;
This means $color will be blue unless it was already set to something else.
Click to reveal answer
intermediate
Why use !default in Sass variables?
It helps avoid overwriting variables when importing files. You can set a default style but allow users to customize by setting the variable before importing.
Click to reveal answer
beginner
What happens if you set a variable without !default after it was already set?
The new value will overwrite the old one, no matter what. !default prevents overwriting if the variable exists.
Click to reveal answer
beginner
Can !default be used with any Sass variable type?
Yes, it works with colors, numbers, strings, lists, maps, or any value type in Sass.
Click to reveal answer
What does $font-size: 16px !default; do if $font-size is already set to 14px?
ARemoves $font-size variable
BSets $font-size to 16px anyway
CThrows an error
DKeeps $font-size as 14px
Why is !default useful when creating reusable Sass libraries?
AIt forces users to change variables
BIt allows users to override variables before import
CIt prevents variables from being set
DIt deletes unused variables
Which of these is a correct way to set a default variable in Sass?
A$color: red !default;
B$color: red default;
C$color = red !default;
D$color !default: red;
If you want to ensure a variable is always set to a specific value, should you use !default?
ANo, omit !default to force the value
BNo, use !important instead
CYes, but only for colors
DYes, always use !default
Can !default be used multiple times on the same variable in different files?
AYes, it overwrites each time
BNo, it causes errors
CYes, the first set value stays
DNo, only one !default per project
Explain how the !default flag works in Sass variables and why it is useful.
Think about how you can set a backup value that only applies if no other value exists.
You got /4 concepts.
    Describe a real-life situation where using !default in Sass variables would help you manage styles better.
    Imagine you make a button style library others use and want them to change colors easily.
    You got /4 concepts.