Write maintainable CSS with variables, nesting, mixins, modules, maps, and compiled output.
Lessons
Pick between two values inline.
The if() Function is easiest to learn by reading the example, changing it, and observing the result.
@use 'sass:math';
@function rem($px, $base: 16px) {
@return math.div($px, $base) * 1rem;
}
.title {
font-size: rem(24px); // 1.5rem
padding: rem(8px); // 0.5rem
}Practice the The if() Function example in a small scratch file, then explain what changed and why.