0
0
SASSmarkup~20 mins

Namespace control with @use as in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Namespace 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 code using @use with alias?
Given the Sass partial _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;
}
A
.button {
  color: $primary;
}
B
.button {
  color: #3498db;
}
C
.button {
  color: colors.$primary;
}
D
.button {
  color: c.primary;
}
Attempts:
2 left
💡 Hint
Remember that @use with an alias requires referencing variables with the alias and a $ sign.
🧠 Conceptual
intermediate
1:30remaining
Which statement about @use with alias is true?
Consider the Sass statement: @use 'theme' as t;
Which of the following is correct?
AThe alias 't' replaces the variable names inside 'theme'.
BVariables from 'theme' can be accessed directly without prefix.
CThe alias 't' is only used for mixins, not variables.
DVariables from 'theme' must be accessed with <code>t.$variableName</code>.
Attempts:
2 left
💡 Hint
Think about how @use controls variable access with namespaces.
selector
advanced
2:00remaining
What CSS selector is generated by this Sass code using @use with alias?
Given @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;
}
A
.btn-primary {
  border-radius: btn.5px;
}
B
.btn-primary {
  @include rounded;
}
C
.btn-primary {
  border-radius: 5px;
}
D
.btn-primary {
  border-radius: 0;
}
Attempts:
2 left
💡 Hint
Mixins from a used file with alias must be included with the alias prefix.
layout
advanced
2: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?
Ab.$spacing always refers to the original $spacing in _base.scss, ignoring local $spacing.
BThe local $spacing in _layout.scss overrides b.$spacing for margin.
CAn error occurs because $spacing is defined twice.
DThe margin uses the global $spacing variable, not b.$spacing.
Attempts:
2 left
💡 Hint
Think about how @use creates a namespace that isolates variables.
accessibility
expert
3: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?
AIt prevents accidental overwriting of color variables, ensuring consistent accessible colors.
BIt automatically adjusts colors for contrast based on alias name.
CIt merges all color variables into one global namespace, simplifying overrides.
DIt disables color variables to force inline styles for accessibility.
Attempts:
2 left
💡 Hint
Think about how namespaces help avoid conflicts and maintain consistency.