Sass Map Functions
Sass Map Functions
Sass Map Functions are used to work with maps (key–value pairs).
Maps are extremely powerful for themes, color systems, breakpoints, spacing scales, and configuration-based CSS.
🔹 What Is a Map in Sass?
A map stores values as key: value pairs.
🔹 Common Sass Map Functions
1️⃣ map-get()
Gets the value of a key.
✔ Output:
2️⃣ map-has-key()
Checks if a key exists.
✔ Output:
3️⃣ map-keys()
Returns all keys as a list.
✔ Output:
4️⃣ map-values()
Returns all values as a list.
✔ Output:
5️⃣ map-merge()
Merges two maps.
6️⃣ map-remove()
Removes one or more keys.
7️⃣ map-deep-merge() (Advanced)
Merges nested maps.
🔹 Looping Through Maps (@each)
✔ Output:
🔹 Nested Map Example (Breakpoints)
Usage:
🔹 Real-Life Use Case (Theme System)
❗ Best Practices
✔ Use maps for configurations
✔ Combine with mixins
✔ Prefer maps over multiple variables
✔ Keep map keys simple
📌 Summary
-
Maps store key–value pairs
-
Very useful for themes & responsive design
-
Powerful built-in functions
-
Works best with loops & mixins
