Spacing Scale Generation with Sass
📖 Scenario: You are creating a consistent spacing scale for a website using Sass. This scale will help keep margins and paddings uniform across the site.
🎯 Goal: Build a Sass map called $spacing-scale with specific spacing values, then create a variable for the base spacing unit, generate a new map with doubled spacing values, and finally output CSS custom properties for these spacing values.
📋 What You'll Learn
Create a Sass map named
$spacing-scale with keys small, medium, and large and values 0.5rem, 1rem, and 2rem respectively.Create a variable named
$base-spacing and set it to 1rem.Generate a new Sass map named
$double-spacing by multiplying each value in $spacing-scale by 2.Output CSS custom properties for each key in
$double-spacing inside the :root selector.💡 Why This Matters
🌍 Real World
Spacing scales help keep website design consistent and easy to update by centralizing spacing values.
💼 Career
Front-end developers use Sass maps and loops to manage design tokens like spacing, colors, and fonts efficiently.
Progress0 / 4 steps