Challenge - 5 Problems
Theming Mixins Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output CSS of this SASS mixin usage?
Given the following SASS code, what CSS will be generated?
$primary-color: #3498db;
@mixin theme-colors($color) {
background-color: $color;
color: white;
}
.button {
@include theme-colors($primary-color);
}SASS
$primary-color: #3498db; @mixin theme-colors($color) { background-color: $color; color: white; } .button { @include theme-colors($primary-color); }
Attempts:
2 left
💡 Hint
Remember that SASS variables are replaced with their values when compiled.
✗ Incorrect
The mixin uses the variable $primary-color which is set to #3498db. When included, the CSS output replaces the variable with its value.
🧠 Conceptual
intermediate1:30remaining
Which option correctly explains the purpose of mixins in theming?
Why do developers use mixins when creating themes in SASS?
Attempts:
2 left
💡 Hint
Think about how mixins help avoid repeating code.
✗ Incorrect
Mixins allow you to write reusable blocks of CSS that can accept parameters, making it easy to apply consistent styles with variations.
❓ selector
advanced2:00remaining
What CSS selector is generated by this SASS code using a mixin?
Consider this SASS code:
What is the correct CSS selector for the hover style?
@mixin theme-button($bg-color) {
background-color: $bg-color;
border: none;
padding: 1rem;
}
.primary {
@include theme-button(#007bff);
}
.primary:hover {
background-color: darken(#007bff, 10%);
}What is the correct CSS selector for the hover style?
SASS
@mixin theme-button($bg-color) { background-color: $bg-color; border: none; padding: 1rem; } .primary { @include theme-button(#007bff); } .primary:hover { background-color: darken(#007bff, 10%); }
Attempts:
2 left
💡 Hint
Remember how CSS pseudo-classes are written.
✗ Incorrect
The hover pseudo-class is attached directly to the element's class with no space, so '.primary:hover' is correct.
❓ layout
advanced1:30remaining
How does using a theming mixin affect layout consistency?
If a mixin sets padding and margin for buttons in a theme, what is the main benefit for layout?
Attempts:
2 left
💡 Hint
Think about how consistent spacing affects design.
✗ Incorrect
Using mixins to set padding and margin ensures uniform spacing, which helps keep the layout neat and balanced.
❓ accessibility
expert2:30remaining
Which mixin usage best supports accessible theming for color contrast?
You want to create a mixin that sets background and text colors ensuring good contrast for readability. Which SASS mixin usage below best supports accessibility?
SASS
@mixin accessible-theme($bg, $text) { background-color: $bg; color: $text; @if (contrast($bg, $text) < 4.5) { color: adjust-color($text, $lightness: 50%); } }
Attempts:
2 left
💡 Hint
Good contrast means text stands out clearly from background.
✗ Incorrect
Option A uses black background and white text, which has excellent contrast and is accessible. Other options have poor or no contrast.