I have three Sass maps that I want to merge into one map. With the map-merge function I can only merge two maps together. How can I merge more than two maps?
A short
I realize this is a bit late, but since this was the only solution I could find while googling I want to post this for others looking for a similar solution.
I stumbled upon this question trying to find the same answer, and while @cimmanon's answer may work for your specific example of combining only 3 maps, it isn't a good solution if you wanted to combine, say 10 maps. I wanted a solution that could be applied to 3 maps or 50. So I wrote a function to handle merging multiple maps together:
@function map-collect($maps...) {
$collection: ();
@each $map in $maps {
$collection: map-merge($collection, $map);
}
@return $collection;
}
And use it like so:
$colors: map-collect($color-name, $color-event, $color-category);
Since this uses the map-merge
function, SASS 3.3+ is required.