Reputation: 15424
I've inherited a project and it has a variable list/map in its scss file, which has:
$palette: (
success: #53a646,
warning: #faa41a,
alert: #ec5840,
);
I want to use one of these variables (warning
) and apply it to an element. I've googled but have not been able to find a way to apply it.
I've seen examples like:
.warning-btn {
background-color: nth($palette, 2);
}
But this isn't working for me.
Would anyone know the correct way of applying the variable to an element?
Upvotes: 0
Views: 37
Reputation: 7496
change your code to the following
$palette: (
success: #53a646,
warning: #faa41a,
alert: #ec5840,
);
.warning-btn {
background-color:#{map-get($palette,warning)}
}
Hope it helps
Upvotes: 2