Saturate and desaturate change how vivid or dull a color looks. They help make colors more lively or more gray.
Saturate and desaturate in SASS
color.saturate($color, $amount) color.desaturate($color, $amount)
$color is the color you want to change.
$amount is how much to increase or decrease saturation, usually in percentages.
$bright-blue: color.saturate(#3498db, 20%);
$dull-red: color.desaturate(#e74c3c, 30%);
button {
background-color: color.saturate(#2ecc71, 15%);
}alert {
color: color.desaturate(#f1c40f, 40%);
}This example shows the original blue color as the page background. Then it shows a box with the color made 30% more colorful and another box with the color made 50% less colorful. You can see how saturation changes the color's vividness.
@use 'sass:color'; $original-color: #3498db; // blue $more-saturated: color.saturate($original-color, 30%); $less-saturated: color.desaturate($original-color, 50%); body { background-color: $original-color; color: white; font-family: Arial, sans-serif; padding: 2rem; } .more-saturated { background-color: $more-saturated; padding: 1rem; margin-top: 1rem; } .less-saturated { background-color: $less-saturated; padding: 1rem; margin-top: 1rem; }
Saturation changes how pure or gray a color looks without changing its lightness.
Use small steps (like 10-30%) to avoid colors looking unnatural.
These functions work best with colors in hex, rgb, or named formats.
Saturate makes colors more vivid.
Desaturate makes colors duller and more gray.
Use them to adjust color moods easily in your styles.
Practice
saturate() function do to a color in Sass?Solution
Step 1: Understand the purpose of saturate()
Thesaturate()function increases the intensity of the color's saturation, making it look more vivid.Step 2: Compare with other effects
Unlike darkening or lightening, saturate specifically boosts color brightness and vividness.Final Answer:
Makes the color more vivid and bright -> Option BQuick Check:
saturate() = more vivid color [OK]
- Confusing saturate() with lighten() or darken()
- Thinking saturate() changes transparency
- Assuming saturate() makes color dull
Solution
Step 1: Recall the function syntax
Thedesaturate()function takes two arguments separated by a comma: the color and the percentage to reduce saturation.Step 2: Identify correct punctuation and units
The percentage must have a percent sign (%) and be separated by a comma, sodesaturate(#ff0000, 20%)is correct.Final Answer:
desaturate(#ff0000, 20%) -> Option CQuick Check:
Correct syntax uses comma and percent sign [OK]
- Omitting the comma between arguments
- Using decimal instead of percentage
- Using semicolon instead of comma
$color: #6699cc; $new-color: saturate($color, 30%);
Solution
Step 1: Understand saturate effect on #6699cc
The color #6699cc is a medium blue. Applyingsaturate($color, 30%)increases its saturation, making it more vivid.Step 2: Compare options
A more vivid blue than #6699cc correctly describes the result. The unchanged option is incorrect because the color changes. The duller, grayer option is incorrect because saturate increases vividness. The lighter blue option is incorrect because saturate does not lighten the color.Final Answer:
A more vivid blue than #6699cc -> Option AQuick Check:
saturate() = more vivid color [OK]
- Thinking saturate lightens the color
- Assuming saturate makes color duller
- Believing color stays unchanged
$color: #00ff00; $new-color: desaturate $color 50%;
Solution
Step 1: Check function call syntax
In Sass, functions require parentheses around their arguments. The code misses parentheses around$colorand50%.Step 2: Verify other parts
The color format#00ff00is valid, and the percentage is correctly given as 50%. The function namedesaturateis correct for reducing saturation.Final Answer:
Missing parentheses around function arguments -> Option DQuick Check:
Functions need parentheses [OK]
- Omitting parentheses in function calls
- Confusing saturate and desaturate functions
- Using decimal instead of percentage
#ff6600 but looks less intense on hover by reducing saturation by 40%. Which Sass code correctly achieves this?Solution
Step 1: Identify the goal
The button's hover state should have the base color with 40% less saturation, sodesaturate($base-color, 40%)is needed.Step 2: Check syntax and logic
$base-color: #ff6600; button { background-color: $base-color; &:hover { background-color: desaturate($base-color, 40%); } } uses correct syntax with parentheses and comma, and applies desaturate correctly on hover. $base-color: #ff6600; button { background-color: $base-color; &:hover { background-color: saturate($base-color, 40%); } } incorrectly saturates instead of desaturates. $base-color: #ff6600; button { background-color: $base-color; &:hover { background-color: desaturate($base-color 40%); } } misses the comma between arguments. $base-color: #ff6600; button { background-color: $base-color; &:hover { background-color: lighten($base-color, 40%); } } uses lighten, which changes brightness, not saturation.Final Answer:
Code with desaturate($base-color, 40%) and correct syntax -> Option AQuick Check:
Desaturate with parentheses and comma [OK]
- Using saturate instead of desaturate
- Omitting comma between arguments
- Using lighten instead of desaturate
Ready to prove it?
Pass the test and this pattern moves unknown
