The mixin is included without any parameter, which causes an error.
Final Answer:
Mixin is included without required parameter -> Option D
Quick Check:
Missing parameter in @include = Mixin is included without required parameter [OK]
Hint: Always pass required parameters when including mixins [OK]
Common Mistakes:
Forgetting to pass parameters to mixins
Assuming default parameters without defining them
Ignoring error messages about missing arguments
5. You want to create a theme mixin that sets background and text colors, but if no text color is provided, it should default to black. Which mixin definition correctly implements this behavior?
C. @mixin theme($bg-color) {
background-color: $bg-color;
color: black;
}
D. @mixin theme($bg-color, $text-color) {
background-color: $bg-color;
color: $text-color;
}
Solution
Step 1: Understand default parameter usage
In Sass, default values for parameters are set using $param: default syntax.
Step 2: Check each option for default text color
@mixin theme($bg-color, $text-color: black) {
background-color: $bg-color;
color: $text-color;
} sets $text-color default to black, so if omitted, black is used.
Step 3: Verify other options
@mixin theme($bg-color, $text-color) {
background-color: $bg-color;
color: if($text-color, $text-color, black);
} tries to use if() function incorrectly; @mixin theme($bg-color) {
background-color: $bg-color;
color: black;
} lacks text color parameter; @mixin theme($bg-color, $text-color) {
background-color: $bg-color;
color: $text-color;
} has no default.