0
0
SASSmarkup~20 mins

Theming with mixins in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Theming Mixins Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2: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);
}
A
.button {
  background-color: blue;
  color: white;
}
B
.button {
  background-color: $primary-color;
  color: white;
}
C
.button {
  background-color: #3498db;
  color: white;
}
D
.button {
  background-color: #000000;
  color: white;
}
Attempts:
2 left
💡 Hint
Remember that SASS variables are replaced with their values when compiled.
🧠 Conceptual
intermediate
1:30remaining
Which option correctly explains the purpose of mixins in theming?
Why do developers use mixins when creating themes in SASS?
ATo reuse a set of CSS properties with different values easily across multiple selectors.
BTo create new HTML elements dynamically in the stylesheet.
CTo store JavaScript functions inside SASS files.
DTo automatically minify CSS files during compilation.
Attempts:
2 left
💡 Hint
Think about how mixins help avoid repeating code.
selector
advanced
2:00remaining
What CSS selector is generated by this SASS code using a mixin?
Consider this SASS code:
@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%);
}
A.primary :hover
B.primary:hovered
C:hover.primary
D.primary:hover
Attempts:
2 left
💡 Hint
Remember how CSS pseudo-classes are written.
layout
advanced
1: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?
AIt changes button sizes randomly to create a dynamic layout.
BIt ensures all buttons have consistent spacing, improving visual alignment across the site.
CIt disables all margins and paddings for buttons to save space.
DIt automatically centers all buttons horizontally on the page.
Attempts:
2 left
💡 Hint
Think about how consistent spacing affects design.
accessibility
expert
2: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%);
  }
}
A@include accessible-theme(#000000, #ffffff);
B@include accessible-theme(#ffffff, #eeeeee);
C@include accessible-theme(#123456, #123456);
D@include accessible-theme(#ff0000, #ff0000);
Attempts:
2 left
💡 Hint
Good contrast means text stands out clearly from background.