Unlike JavaScript symbols (!, &&, ||), Sass uses words for boolean logic: not, and, and or. They run at compile time (often inside @if).
Official sample idea.
not true is false; true and false is false; true or false is true.
Truthiness.
Anywhere true/false are allowed, other values work too. Only false and null are falsey.
0 and "" are truthy.
Empty strings, empty lists, and 0 are truthy in Sass—unlike many other languages.
Syntax
Syntax
SCSS
not $expr // opposite of $expr
$a and $b // true if both truthy
$a or $b // true if either truthy
not true; // false
not false; // true
true and true; // true
true and false; // false
true or false; // true
false or false; // false
// Typical use:
@if $dark and not $compact { ... }
Pattern: build a condition with words → branch with @if → emit different CSS at compile time.
string.index fits naturally as a truthy/null check.
One line: combine conditions with not, and, and or—remember only false and null are falsey.
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Use not / and / or (not ! && ||)
2. Treat only false and null as falsey
3. Branch with @if / @else
4. Use string.index(...) directly in conditions when useful
5. Prefer equality/relational ops when testing 0 or ""
Frequently Asked Questions
Unlike JavaScript symbols (!, &&, ||), Sass uses words: not, and, and or. They combine or invert boolean values at compile time.
not returns the opposite of an expression’s value: not true is false, and not false is true. With truthiness, not null is true.
and returns true when both sides are truthy, and false when either side is falsey.
or returns true when either side is truthy, and false when both sides are falsey.
Only false and null. Empty strings, empty lists, and the number 0 are all truthy in Sass—unlike some other languages.
Use string.index($string, " "). It returns null when missing (falsey) and a number when found (truthy), so it works directly in @if.