Accessing map values with map-get in Sass
📖 Scenario: You are creating a simple style guide for a website. You want to store colors in a Sass map and then use those colors in your CSS rules.
🎯 Goal: Build a Sass stylesheet that defines a color map and uses map-get to apply colors to CSS selectors.
📋 What You'll Learn
Create a Sass map named
$colors with specific color names and hex valuesCreate a variable named
$primary-color that gets the value of blue from the $colors map using map-getUse the
$primary-color variable to set the background color of the body selectorAdd a CSS rule for
h1 that uses map-get directly to set the text color to red from the $colors map💡 Why This Matters
🌍 Real World
Using Sass maps helps keep your styles organized and makes it easy to update colors or other values in one place.
💼 Career
Many front-end developers use Sass maps and map-get to manage design tokens and theme variables efficiently in real projects.
Progress0 / 4 steps