An if statement is handy for checking if a variable exists or matches something:
$var: true !default; // Can be overridden elsewhere
@if $var == true {
// Conditional code
}
$other: single;
@if $other == single {
// Code for if itβs single
} @else if $other == double {
// Double code
} @else {
// Default if itβs neither
}

This affiliate banner helps support the site π
Make sure that if your variable properties are stored with β
quotes around them, your @if
statement checks that too. (e.g. $other ==βsingleβ
).
if
statements can be useful for mixins for checking variables or in libraries to include or exclude code.