localhost
localhost

Reputation: 871

Mixin not outputting @each function

I am trying out @each which works fine without @mixin but when I make it flexible with @mixin it doesn't output anything. I cannot figure out what am I missing?

$buttons : (
    default : $color-primary,
    success : #63cc82,
    error   : #e4757e,
    warning : #fd7856,
    info    : #927bc1,
)

mixin

@mixin themes($map){
    @each $button, $color in $map {
        &--#{$button}{
            background:$color;
        }
    }
}

and I am calling it like

@include themes(buttons)

Upvotes: 1

Views: 22

Answers (1)

Sam Willis
Sam Willis

Reputation: 4211

You need to pass in your map as a variable like so:

@include themes($buttons)

Upvotes: 1

Related Questions