I'd like to check in SASS if a color is white, black, or a nuance of grey.
Exemple :
If color is red => apply my css If color is "#000" or "#686868" => don't apply my css
Is there any solution using SASS or native CSS ?
I'd like to check in SASS if a color is white, black, or a nuance of grey.
Exemple :
If color is red => apply my css If color is "#000" or "#686868" => don't apply my css
Is there any solution using SASS or native CSS ?
Thanks for clarification your question in comment.
Indeed there is an easy possibility in SASS to check if color is a gray color
Use: @if $color == grayscale($color) { ... }
See documentation: https://sass-lang.com/documentation/modules/color#grayscale
If you want to wrap that in a function do:
@function is_gray($color){
$result: false;
@if $color == grayscale($color){
$result: true;
}
@return $result;
}
// than call ...
@if is_gray($test){
...
}