Sass is outputting #000 and #fff as black and white color values in my css file. For example:
$color: #000;
.box {
color: $color;
}
Outputs to:
.box {
color: black;
}
Shouldn't output the hex values?
Sass is outputting #000 and #fff as black and white color values in my css file. For example:
$color: #000;
.box {
color: $color;
}
Outputs to:
.box {
color: black;
}
Shouldn't output the hex values?
How Sass treats colors varies depending on what version you're using. But there are a few common behaviors:
rgba(0, 0, 0, 100)
, Sass will convert it to eitherblack
or#000
)#000000
will be output as#000
).Sass 3.3 and older
Sass only converts colors when they are used as variables or if they are not in one of the 3 formats as described above:
Output:
Sass 3.4 and later
The only change from 3.3 to 3.4 is that when using variables, Sass will preserve the format of your color... unless it is in something other than the keyword, hex, or rgba formats.
But what if I really need a specific format?
If you absolutely must have a specific format, you can turn it into a string:
Output:
Just keep in mind that when you do this, your "color" will not work with color manipulation functions like
lighten()
ordarken()
.