0
0
SASSmarkup~5 mins

Mixins with parameters in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a mixin in Sass?
A mixin is a reusable block of styles that you can include in other selectors. It helps avoid repeating code.
Click to reveal answer
beginner
How do you define a mixin with parameters in Sass?
Use @mixin followed by the mixin name and parentheses with parameters inside. Example: @mixin box($color) { background-color: $color; }
Click to reveal answer
beginner
How do you include a mixin with parameters in a selector?
Use @include with the mixin name and pass the arguments in parentheses. Example: @include box(red);
Click to reveal answer
beginner
Why use parameters in mixins?
Parameters let you customize the styles inside the mixin each time you use it, making your code flexible and reusable.
Click to reveal answer
intermediate
What happens if you define a default value for a mixin parameter?
If you don't pass a value when including the mixin, the default value is used automatically.
Click to reveal answer
How do you pass a color parameter to a mixin named button-style?
Abutton-style(red);
B@mixin button-style(red);
C@include button-style(red);
D@include button-style { red; }
What keyword starts the definition of a mixin in Sass?
A@extend
B@include
C@function
D@mixin
What is the benefit of using parameters in mixins?
AThey make mixins reusable with different values.
BThey make CSS load faster.
CThey automatically create variables.
DThey prevent styles from being applied.
If a mixin parameter has a default value, what happens when you don't pass that parameter?
AThe default value is used.
BAn error occurs.
CThe parameter is ignored.
DThe mixin is skipped.
Which of these is a valid mixin definition with a parameter?
A@function border-radius($radius) { border-radius: $radius; }
B@mixin border-radius($radius) { border-radius: $radius; }
Cborder-radius($radius) { border-radius: $radius; }
D@include border-radius($radius) { border-radius: $radius; }
Explain how to create and use a mixin with parameters in Sass.
Think about how you make reusable style blocks that accept inputs.
You got /3 concepts.
    Describe the advantage of giving default values to mixin parameters.
    Consider what happens if you forget to pass a value.
    You got /3 concepts.