Curriculum
Course: Sass Functions
Login
Text lesson

Sass Map Functions

Sass Map Functions

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:
#00ff00

map-merge($map1, $map2)

Produces a map with $map2 added to the end of $map1.

map-merge((“red”: #ff0000, “green”: #00ff00), (“blue”: #0000ff)

Result:
(“red”: #ff0000, “green”: #00ff00, “blue”: #0000ff)

map-remove($map, $keys)

Produces a map excluding the specified keys.

map-remove((“red”: #ff0000, “green”: #00ff00), “red”)

Result:
(“green”: #00ff00)

map-keys($map)

Generates a list containing the keys found in the provided map.

map-keys((“red”: #ff0000, “green”: #00ff00))

Result:
(“red”, “green”)

map-values($map)

Produces a list containing the values found in the specified map.

map-values((“red”: #ff0000, “green”: #00ff00))

Result:
(#ff0000, #00ff00)

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:
false