map.get()
The modified map.get() function returns the value associated with $key in $map, and returns $fallback if returned is null.
// Sass.
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';
// The `map.get()` function.
@function get($map, $key, $fallback: null) {
@return if(
meta.type-of($map) == map and list.length($key) > 0,
if(
list.separator($key) == comma,
map.get($map, $key...),
map.get($map, $key)
),
$fallback
)
or $fallback;
}https://github.com/angular-package/sass/blob/main/map/_map.get.function.scss
Parameters
$map
$mapA map to get the value by using $key.
$key
$keyThe key used to get the value from $map.
$fallback: null
$fallback: nullThe fallback value if returned is null.
Return
The return value is the value associated with $key from $map, if null returns $fallback.
Examples
Last updated
Was this helpful?