0
0
SASSmarkup~5 mins

@import to @use migration in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main difference between @import and @use in Sass?

@import includes styles multiple times and can cause conflicts. @use loads styles once and keeps them in a namespace to avoid conflicts.

Click to reveal answer
beginner
How do you replace <code>@import 'colors';</code> with <code>@use</code>?

Use @use 'colors'; instead. This loads the colors file once and requires you to prefix variables or mixins with colors..

Click to reveal answer
intermediate
Why does @use help avoid variable conflicts?

Because @use creates a namespace for the imported file. You must write namespace.$variable, so variables with the same name in different files don’t clash.

Click to reveal answer
intermediate
How can you shorten the namespace when using @use?

You can add as * to @use like @use 'colors' as *; to use variables without the namespace prefix, but use it carefully to avoid conflicts.

Click to reveal answer
intermediate
What should you do if you want to share variables or mixins globally with @use?

Create a separate file for shared variables and @use it in each file that needs them. This keeps your code organized and avoids duplication.

Click to reveal answer
Which Sass directive loads a file only once and uses namespaces?
A@use
B@import
C@forward
D@mixin
How do you access a variable named $color from a file loaded with @use 'theme';?
A$color
Btheme.color
Ctheme.$color
Dtheme.$color()
What does @use 'colors' as *; do?
AImports colors with the namespace 'colors'
BImports colors without any namespace
CImports colors multiple times
DImports colors as a mixin
Why should you avoid using @import in new Sass projects?
AIt is required for variables
BIt is faster than @use
CIt supports namespaces
DIt is deprecated and can cause duplicate styles
Which directive allows you to re-export styles from one file to another in Sass?
A@forward
B@use
C@import
D@mixin
Explain how to migrate a Sass project from using @import to @use. What are the key steps and benefits?
Think about how @use changes the way you access variables and why it is better.
You got /4 concepts.
    Describe how namespaces work in Sass when using @use. Why are they important?
    Consider how multiple files can have the same variable names.
    You got /4 concepts.