How to set background color to <div> with $color variable?

$colors: ( primary: #387ef5, secondary: #32db64, danger: #f53d3d, light: #f4f4f4, dark: #222, );
<div>Foo</div>

I wan to set background color of div by #387ef5(primary), how can I?

The following do not worked:

<div color="primary">Foo</div>

Have you tried to use the normal class attribute like <div class="colored_div"> and put the $color variable at the style definition file?

I think it’ll resolv your problem.

give a class name to your div like then in scss background-color:map-get($colors,primary);