Functions and operators
Compute values with colour functions, maps and arithmetic.
What you will be able to do
- Use lighten/darken carefully; prefer colour spaces.
- Use map-get to read token maps.
- Use math.div for division.
- Write @function for reusable calculations.
In plain English
Sass functions transform values at build time. Colour functions adjust lightness and alpha; map functions read scales; math functions compute spacing. Use @function for your own calculations.
@use "sass:map";
@use "sass:math";
$space: (sm: 8px, md: 16px);
@function space($key) {
@return map.get($space, $key);
}
.card { padding: space(md); }Your turn
EasyRead a map value
Return the md value from a $space map.
SCSS · starter
@function space($key) {Check your understanding before moving on.
Knowledge checkQuestion 1
Which module provides map.get?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.