Colours
Colour helpers take colour names, #rgb, #rrggbb, #rrggbbaa, rgb() and hsl().
Opacity and mixing
@alpha() sets a colour's opacity. @mix() blends two colours, half and half unless you give an amount:
.overlay { background: {@alpha('#3355ff', 0.2)}; }
.tint { background: {@mix('#3355ff', 'white', 0.25)}; } /* a quarter of the way to white */Lightness
@adjust_lightness() adds to a colour's HSL lightness, keeps it between 0% and 100%, and returns CSS text. A positive amount makes the colour lighter, and a negative one darker. @lighten() and @darken() do the same with a positive amount:
.button:hover { background: {@adjust_lightness('#3355ff', '-10%')}; }
.button:active { background: {@darken('#3355ff', '20%')}; }
.badge { background: {@lighten('red', 0.5)}; } /* #ffffff */A native color value in a script is different. Its ->lighten() and ->darken() mix the colour's red, green and blue towards white or black, and return another color. With $brand: color = red, $brand->lighten(0.5) gives #ff8080, halfway to white, while @lighten('red', 0.5) adds 50 points to red's 50% lightness and reaches white.
Readable text
@contrast_color() picks black or white, whichever reads better on a colour. Give it your own dark and light colours as the second and third arguments:
.button { color: {@contrast_color('#3355ff')}; }
.tag { color: {@contrast_color('#ffcc00', '#222', '#fafafa')}; }