0
0
SASSmarkup~20 mins

@forward directive for re-exporting in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Forwarding Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What does the @forward directive do in Sass?
Choose the best description of what the @forward directive accomplishes in Sass.
AIt imports styles from another file and makes them available only in the current file.
BIt re-exports styles from another file, making them available to files that import the current file.
CIt compiles Sass files into CSS without combining any styles.
DIt removes unused CSS rules from the final stylesheet.
Attempts:
2 left
💡 Hint
Think about sharing styles through multiple files.
📝 Syntax
intermediate
1:30remaining
Which @forward syntax correctly forwards all styles from _buttons.scss?
Select the correct Sass code to forward all styles from the file named _buttons.scss.
A@forward './buttons.scss';
B@forward buttons;
C@forward "buttons";
D@forward "./buttons";
Attempts:
2 left
💡 Hint
Remember to use quotes and omit the underscore and extension.
rendering
advanced
2:00remaining
What CSS output results from forwarding variables and mixins?
Given these Sass files, what CSS will be generated when compiling main.scss?
SASS
@forward "colors";

// colors.scss
$primary: #06c;
@mixin button-style {
  background-color: $primary;
  color: white;
}

// main.scss
@use "buttons";
.button {
  @include buttons.button-style;
}
A
.button {
  background-color: #000;
  color: white;
}
B
.button {
  background-color: $primary;
  color: white;
}
CError: Undefined mixin 'buttons.button-style'.
D
.button {
  background-color: #06c;
  color: white;
}
Attempts:
2 left
💡 Hint
Forwarding makes variables and mixins available through the module.
selector
advanced
2:00remaining
How does @forward affect selector scope in Sass modules?
If _base.scss defines styles for body and is forwarded by _theme.scss, which file's styles apply when importing theme.scss?
SASS
// base.scss
body { background: white; }

// theme.scss
@forward "base";

// main.scss
@use "theme";
AStyles from base.scss apply because they are forwarded by theme.scss.
BStyles from base.scss do not apply because @forward only shares variables, not selectors.
CStyles from base.scss apply only if explicitly imported in main.scss.
DNo styles apply because @forward disables selector output.
Attempts:
2 left
💡 Hint
Think about what @forward shares besides variables.
accessibility
expert
2:30remaining
How can @forward help maintain accessible design tokens across Sass files?
You want to keep color variables for accessible contrast consistent across your project. How does using @forward help achieve this?
ABy forwarding a single file with color variables, all modules use the same tokens, ensuring consistent accessible colors.
BBy forwarding, each file gets a separate copy of variables, allowing different accessible colors per module.
CForwarding disables variable inheritance, so accessible colors must be redefined in each file.
DForwarding automatically adjusts colors for accessibility based on user preferences.
Attempts:
2 left
💡 Hint
Think about sharing one source of truth for colors.