Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a design token in web development?
A design token is a small, reusable value that stores design decisions like colors, fonts, or spacing. It helps keep styles consistent across a website or app.
Click to reveal answer
beginner
How do design tokens improve collaboration between designers and developers?
Design tokens create a shared language by turning design choices into code variables. This makes it easier for designers and developers to work together and keep the look consistent.
Click to reveal answer
beginner
Show an example of a color design token in Sass.
In Sass, you can create a color token like this:
$primary-color: #3498db;
Then use it in styles:
button { background-color: $primary-color; }
Click to reveal answer
beginner
Why is it better to use design tokens instead of hardcoding values in CSS or Sass?
Using design tokens makes it easy to update styles in one place. If you change a token, all parts of the site using it update automatically, saving time and avoiding mistakes.
Click to reveal answer
beginner
What types of design properties can be stored as tokens?
You can store colors, font sizes, spacing, border radius, shadows, and more as design tokens. Anything that controls the look and feel can be a token.
Click to reveal answer
What is the main purpose of design tokens?
ATo create animations
BTo store reusable design values for consistency
CTo write JavaScript functions
DTo manage database connections
✗ Incorrect
Design tokens store reusable design values like colors and fonts to keep styles consistent.
How do you define a color token in Sass?
Acolor-primary = #3498db;
Bvar(--primary-color: #3498db);
C$primary-color: #3498db;
Dprimary-color: #3498db;
✗ Incorrect
In Sass, variables start with $ and are assigned with a colon, like $primary-color: #3498db;
Which of these is NOT a benefit of using design tokens?
AEasier style updates
BImproved design consistency
CBetter collaboration between teams
DFaster database queries
✗ Incorrect
Design tokens help with styles and collaboration, but do not affect database queries.
Which design property can be stored as a token?
AFont size
BServer IP address
CUser password
DHTML tag names
✗ Incorrect
Font size is a design property suitable for tokens; server info or passwords are not.
If you change a design token value, what happens?
AAll styles using that token update automatically
BOnly the first use of the token changes
CNothing changes until you restart the browser
DThe website crashes
✗ Incorrect
Changing a token updates all styles that use it, ensuring consistent design.
Explain what design tokens are and why they are useful in Sass projects.
Think about how you keep colors or font sizes the same everywhere.
You got /3 concepts.
Describe how you would create and use a design token for spacing in a Sass stylesheet.
Use $spacing-small: 1rem; as an example.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of design tokens in Sass?
easy
A. To write JavaScript functions inside Sass
B. To create animations in Sass
C. To store reusable style values like colors and sizes
D. To manage HTML structure
Solution
Step 1: Understand design tokens concept
Design tokens are variables that hold style values such as colors, fonts, and sizes.
Step 2: Identify their purpose in Sass
They help keep styles consistent and easy to update by reusing these values.
Final Answer:
To store reusable style values like colors and sizes -> Option C
Quick Check:
Design tokens = reusable style values [OK]
Hint: Design tokens store style values for reuse [OK]
Common Mistakes:
Thinking design tokens are for animations
Confusing design tokens with JavaScript code
Believing design tokens manage HTML
2. Which of the following is the correct way to declare a design token for a primary color in Sass?
easy
A. let $primary-color = #3498db;
B. primary-color = #3498db;
C. var primary-color = #3498db;
D. $primary-color: #3498db;
Solution
Step 1: Recall Sass variable syntax
Sass variables start with a dollar sign ($) and use a colon to assign values.
Step 2: Check each option
$primary-color: #3498db; uses correct Sass syntax: $primary-color: #3498db;. Others use JavaScript or invalid syntax.
Final Answer:
$primary-color: #3498db; -> Option D
Quick Check:
Sass variables start with $ and use : [OK]
Hint: Sass variables start with $ and use colon : [OK]
A. Missing semicolon after $color-primary declaration
B. Wrong variable name syntax
C. Using hex colors is not allowed in Sass variables
D. Background color property is invalid
Solution
Step 1: Check variable declarations
$color-primary is missing a semicolon at the end of the line, which is required in Sass.
Step 2: Verify other parts
Variable names and background-color property are correct. Hex colors are valid.
Final Answer:
Missing semicolon after $color-primary declaration -> Option A
Quick Check:
Each Sass variable line must end with ; [OK]
Hint: Always end Sass variable lines with semicolon ; [OK]
Common Mistakes:
Omitting semicolons after variable declarations
Thinking hex colors are invalid in Sass
Misnaming variables without $ sign
5. You want to create a design token system in Sass that allows easy theme switching between light and dark modes. Which approach below best manages color tokens for this purpose?
hard
A. Hardcode colors directly in CSS without variables
B. Define separate maps for light and dark colors, then use a variable to select the active map
C. Use JavaScript to change colors only, ignoring Sass variables
D. Create one set of variables and manually change each color in the stylesheet
Solution
Step 1: Understand theme switching needs
Theme switching requires grouping colors so you can easily swap them based on mode.
Step 2: Evaluate options for managing tokens
Using separate Sass maps for light and dark themes allows selecting the active theme map with a variable, making switching easy and maintainable.
Step 3: Reject other options
Hardcoding colors or manual changes are error-prone and not scalable. JavaScript alone ignores Sass benefits.
Final Answer:
Define separate maps for light and dark colors, then use a variable to select the active map -> Option B
Quick Check:
Use maps and variables for theme switching [OK]
Hint: Use Sass maps and a variable to switch themes [OK]
Common Mistakes:
Hardcoding colors instead of using variables
Ignoring Sass variables and relying only on JavaScript
Manually changing colors everywhere instead of grouping