0
0
SASSmarkup~5 mins

@use directive for imports in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the @use directive do in Sass?
The @use directive imports another Sass file and makes its variables, mixins, and functions available under a namespace.
Click to reveal answer
beginner
How do you access a variable named $color from a file imported with @use 'colors';?
You access it with the namespace like this: colors.$color.
Click to reveal answer
intermediate
Why is @use preferred over @import in modern Sass?
@use avoids variable and mixin conflicts by using namespaces and loads files only once, improving clarity and performance.
Click to reveal answer
intermediate
How can you rename a namespace when using @use?
You can rename it with the as keyword, for example: @use 'colors' as c; then access variables like c.$color.
Click to reveal answer
intermediate
What happens if you use @use multiple times for the same file?
Sass loads the file only once, so multiple @use statements for the same file share the same namespace and do not duplicate code.
Click to reveal answer
What is the main benefit of using @use instead of @import in Sass?
AIt imports CSS files only
BIt creates a namespace to avoid conflicts
CIt allows inline styles
DIt disables variables
How do you access a mixin named button from a file imported as @use 'styles' as s;?
Abutton()
Bs.button()
C@include s.button;
D@include button;
Which keyword lets you rename the namespace when using @use?
Arename
Bnamespace
Cwith
Das
If you want to use variables from a file without a namespace, what can you do?
AUse <code>@use 'file' as *;</code>
BUse <code>@import 'file';</code>
CUse <code>@use 'file' no-namespace;</code>
DUse <code>@use 'file' global;</code>
What happens if you try to import the same file twice with @use?
AThe file is loaded once and shared
BAn error occurs
CThe second import is ignored silently
DThe file is loaded twice
Explain how the @use directive works in Sass and why it is better than @import.
Think about how variables and mixins are accessed and how duplication is prevented.
You got /5 concepts.
    Describe how to rename a namespace when importing a file with @use and how to access a variable from it.
    Remember the pattern: namespace.variable
    You got /3 concepts.