I am trying to create a variable that is equal to nothing. I have tried the following..
$false:null;
-and-
$false:\" \";
Set the variable to 'false'
$false: false;
Sass is written in ruby which uses nil
instead of null
.
@mixin myMixin($myVariable, $myOtherVariable){
$false: nil;
@if $myVariable == $false{
color: inherit;
} @else {
color: $myVariable;
}
}
p {
@include myMixin(nil, $myOtherVariable);
}
.red {
@include myMixin(red, $myOtherVariable);
}
Example on jsFiddle
null
or false
will work (null
is new in the latest version of Sass). Both will work for your example. The only advantage of null
is that it disappears if you use it with a property.
@mixin myMixin($myVariable: false, $myOtherVariable: false){
@if not $myVariable {
//do something
} @else {
//do something else
}
}
@include myMixin(false, $myOtherVariable);