0
0
SASSmarkup~5 mins

Default parameter values in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a default parameter value in Sass?
A default parameter value is a value given to a function or mixin parameter that is used if no other value is provided when calling it.
Click to reveal answer
beginner
How do you set a default parameter value in a Sass mixin?
You assign the value in the parameter list using a colon, like @mixin example($color: blue). If no color is passed, it uses blue.
Click to reveal answer
beginner
What happens if you call a Sass function or mixin without providing a parameter that has a default value?
Sass uses the default value specified for that parameter automatically.
Click to reveal answer
intermediate
Can default parameter values in Sass be expressions or variables?
Yes, default values can be variables or expressions, like $size: 10px * 2 or $color: $primary-color.
Click to reveal answer
beginner
Why are default parameter values useful in Sass?
They let you write flexible mixins and functions that work with or without extra input, making your code easier to reuse and maintain.
Click to reveal answer
How do you define a default parameter value in a Sass mixin?
ABy calling the mixin with a value
BUsing an equal sign, like <code>$color = red</code>
CUsing a colon after the parameter name, like <code>$color: red</code>
DBy setting the value inside the mixin body
What value does a Sass mixin use if you don't provide a parameter with a default value?
AIt uses the default value specified
BIt throws an error
CIt uses null
DIt uses the last value used
Can default parameter values in Sass be variables?
ANo, only fixed values are allowed
BOnly numbers can be used
COnly colors can be used
DYes, variables can be used as default values
Which of these is a correct Sass mixin with a default parameter?
A@mixin box-shadow($shadow = 2px 2px 5px gray) { box-shadow: $shadow; }
B@mixin box-shadow($shadow: 2px 2px 5px gray) { box-shadow: $shadow; }
C@mixin box-shadow($shadow) { box-shadow: $shadow; }
D@mixin box-shadow { box-shadow: 2px 2px 5px gray; }
Why use default parameter values in Sass?
ATo allow mixins and functions to work with or without extra input
BTo make mixins and functions less flexible
CTo avoid writing any parameters
DTo force users to always provide values
Explain how default parameter values work in Sass mixins and why they are helpful.
Think about how you can write mixins that don’t always need all inputs.
You got /4 concepts.
    Describe a simple Sass mixin with a default parameter and what happens when you call it with and without that parameter.
    Imagine a button color that changes if you give a color, or stays default if you don’t.
    You got /3 concepts.