In Sass, the map data type represents collections of key/value pairs.
Tip: Lists functions can be utilized with maps, treating the map as a list with two elements.
Sass maps are immutable, meaning functions returning maps will generate a new map rather than modifying the original.
Below is a comprehensive table listing all map functions available in Sass:
Function |
Description |
Examples |
map-get($map, $key) |
Retrieves the value linked with the given key. |
map-get((“red”: #ff0000, “green”: #00ff00), “green”) Result: |
map-merge($map1, $map2) |
Produces a map with $map2 added to the end of $map1. |
map-merge((“red”: #ff0000, “green”: #00ff00), (“blue”: #0000ff) Result: |
map-remove($map, $keys) |
Produces a map excluding the specified keys. |
map-remove((“red”: #ff0000, “green”: #00ff00), “red”) Result: |
map-keys($map) |
Generates a list containing the keys found in the provided map. |
map-keys((“red”: #ff0000, “green”: #00ff00)) Result: |
map-values($map) |
Produces a list containing the values found in the specified map. |
map-values((“red”: #ff0000, “green”: #00ff00)) Result: |
map-has-key($map, $key) |
Indicates with a Boolean value whether the specified key exists within the given map. |
map-has-key((“red”: #ff0000, “green”: #00ff00), blue) Result: |