Challenge - 5 Problems
Sass Namespace 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 code using @use with alias?
Given the Sass partial
And this main Sass file:
What CSS will be generated?
_colors.scss with:$primary: #3498db;
And this main Sass file:
@use 'colors' as c;
.button {
color: c.$primary;
}What CSS will be generated?
SASS
@use 'colors' as c; .button { color: c.$primary; }
Attempts:
2 left
💡 Hint
Remember that @use with an alias requires referencing variables with the alias and a $ sign.
✗ Incorrect
Using @use 'colors' as c; means you access variables with c.$variableName. The output CSS replaces the variable with its value.
🧠 Conceptual
intermediate1:30remaining
Which statement about @use with alias is true?
Consider the Sass statement:
Which of the following is correct?
@use 'theme' as t;Which of the following is correct?
Attempts:
2 left
💡 Hint
Think about how @use controls variable access with namespaces.
✗ Incorrect
When you use @use with an alias, all variables, mixins, and functions must be accessed with that alias as a prefix.
❓ selector
advanced2:00remaining
What CSS selector is generated by this Sass code using @use with alias?
Given
Assuming
@use 'buttons' as btn; and the Sass:.btn-primary {
@include btn.rounded;
}Assuming
rounded mixin adds border-radius: 5px;, what CSS is output?SASS
@use 'buttons' as btn; .btn-primary { @include btn.rounded; }
Attempts:
2 left
💡 Hint
Mixins from a used file with alias must be included with the alias prefix.
✗ Incorrect
The mixin rounded from buttons is included with btn.rounded, which outputs border-radius: 5px; inside .btn-primary.
❓ layout
advanced2:30remaining
How does @use with alias affect variable scope in nested Sass files?
If
_base.scss defines $spacing: 1rem; and _layout.scss uses @use 'base' as b; and sets margin: b.$spacing;, what happens if $spacing is redefined in _layout.scss?Attempts:
2 left
💡 Hint
Think about how @use creates a namespace that isolates variables.
✗ Incorrect
Using @use with alias creates a namespace. b.$spacing always refers to the variable in _base.scss, unaffected by local variables.
❓ accessibility
expert3:00remaining
How can @use with alias improve accessibility in large Sass projects?
In a large Sass project, how does using
@use 'colors' as c; help maintain accessible color schemes?Attempts:
2 left
💡 Hint
Think about how namespaces help avoid conflicts and maintain consistency.
✗ Incorrect
Using @use with alias creates isolated namespaces, preventing accidental changes to shared color variables, which helps keep color contrast consistent and accessible.