SASS Partials and Modules 2 — Questions and Answers
Question 1: How do you give a `@use`d module a custom namespace alias?
- @use 'module' as alias; (Correct answer)
- @use 'module' named alias;
- @use 'module' => alias;
- @use alias from 'module';
Correct answer: @use 'module' as alias;
The `as` keyword in `@use` assigns a custom namespace to the loaded module.
Question 2: How do you load a module without a namespace in Sass?
- @use 'module' as *; (Correct answer)
- @use 'module' as none;
- @use 'module' global;
- @use 'module' without namespace;
Correct answer: @use 'module' as *;
Using `as *` with `@use` makes all members globally accessible without a namespace prefix.
Question 3: What does `@use 'sass:math'` provide?
- Built-in math functions like `math.pow()`, `math.sqrt()`, and `math.round()` (Correct answer)
- CSS math expressions
- A polyfill for `calc()`
- Float precision settings
Correct answer: Built-in math functions like `math.pow()`, `math.sqrt()`, and `math.round()`
The `sass:math` built-in module provides mathematical functions for use in Sass stylesheets.
Question 4: How do you use the built-in Sass color module?
- @use 'sass:color'; (Correct answer)
- @use 'sass:colors';
- @include sass-color;
- @import 'color';
Correct answer: @use 'sass:color';
The `sass:color` built-in module is loaded with `@use 'sass:color'` and provides color manipulation functions.
Question 5: Which built-in Sass module provides string manipulation functions?
- sass:string (Correct answer)
- sass:text
- sass:str
- sass:strings
Correct answer: sass:string
The `sass:string` module provides functions like `string.quote()`, `string.unquote()`, and `string.index()`.
Question 6: What does `@forward 'module' hide $private-var` do?
- Forwards all module members except `$private-var` (Correct answer)
- Exports only `$private-var`
- Hides the entire module
- Renames `$private-var` when forwarding
Correct answer: Forwards all module members except `$private-var`
The `hide` keyword in `@forward` excludes specified members from being re-exported.
How do you give a `@use`d module a custom namespace alias?