Sass: Boolean Operators
Sass uses words rather than symbols for its boolean operators.
not <expression>
returns the opposite of the expression’s value: it turnstrue
intofalse
andfalse
intotrue
.<expression> and <expression>
returnstrue
if both expressions’ values aretrue
, andfalse
if either isfalse
.<expression> or <expression>
returnstrue
if either expression’s value istrue
, andfalse
if both arefalse
.
Example:
@debug not true; // false
@debug not false; // true
@debug true and true; // true
@debug true and false; // false
@debug true or false; // true
@debug false or false; // false
note
Anywhere true
or false
are allowed, you can use other values as well.
note
The values false
and null
are falsy, which means Sass considers them to indicate falsehood and cause conditions to fail. Every other value is considered truthy, so Sass considers them to work like true
and cause conditions to succeed.