Gerillass

v2.1.0

Is Color

Type: Function
isColor();

Returns the value if every item in it is a colour, and errors otherwise.

Arguments

NameTypeDescription
$valuecolor | listAccepts a colour, or a list of colours.

Examples

Validating a colour argument in a mixin of your own.

Sass
@mixin badge($color) {
  background-color: isColor($color);
  color: white;
}
.badge {
  @include badge(crimson);
}
CSS
.badge {
  background-color: crimson;
  color: white;
}

What it refuses

Arguments are checked, so a wrong value stops the build with a message instead of quietly producing the wrong CSS.

Sass
$brand: crimson;
.badge {
  background-color: isColor(brand);
}
Error: 'brand' is not a color value, please replace it with a valid one.