darken($color, $amount) decreases a legacy color’s HSL lightness by a fixed percentage (0%–100%) and returns a new color. It is a global built-in — there is nocolor.darken().
Large fixed step turns near-white cream into muted brown.
Custom property stores the shadow tone.
In new code, try color.scale(#f2ece4, $lightness: -40%).
Compare the look before locking tokens.
Example 3 — Dark Color + Large Amount → Black (Official Docs)
Lightness 20% minus 30% clamps to black.
SCSS
// #036 has lightness 20%, so when darken() subtracts 30% it just returns black.
@debug darken(#036, 30%); // black
.deep {
color: darken(#036, 30%);
}
Compiled CSS
.deep {
color: black;
}
How It Works
#036 lightness is 20%.
Subtract 30% → below zero → black.
You asked for “a bit darker” and wiped the color out.
Classic reason official docs discourage darken.
Example 4 — Prefer color.scale() (Official Docs)
Same seed color, relative 30% darkening keeps a visible navy.
SCSS
@use "sass:color";
// scale() instead makes it 30% darker than it was originally.
@debug color.scale(#036, $lightness: -30%); // #002447
.deep {
--darken: #{darken(#036, 30%)};
--scale: #{color.scale(#036, $lightness: -30%)};
}
Compiled CSS
.deep {
--darken: black;
--scale: #002447;
}
How It Works
Side-by-side shows the trap vs the fix.
darken collapses to black.
scale keeps usable dark blue #002447.
Prefer scale in new SCSS for hover / shadow tones.
Example 5 — Preserve Old Math with color.adjust()
Match darken(#b37399, 20%) exactly when migrating.
Deprecated: fixed HSL lightness subtraction on legacy colors.
Prefer color.scale for “percent darker.”
Use color.adjust when you must match old pixels.
No module form — there is no color.darken().
One line: learn darken to read legacy SCSS; write scale (or adjust) in new code.
Migrate
Migrate Notes
Conceptual flow:
flow.txt
1. Find darken($color, $amount)
2. Want "% darker"? → color.scale($color, $lightness: -$amount)
3. Need same pixels? → color.adjust($color, $lightness: -$amount, $space: hsl)
4. @use "sass:color"
5. Delete the global darken() call
Frequently Asked Questions
darken($color, $amount) decreases a legacy color’s HSL lightness by $amount (0%–100%). Example: darken(#b37399, 20%) is #7c4465.
Yes. Official Sass docs list it under Deprecated Functions and omit it from the sass:color module. Prefer color.scale() for relative darkening, or color.adjust($color, $lightness: -$amount, $space: hsl) to keep the old math.
Because darken() is usually not the best way to darken a color, it is not included in the new module system. Use color.scale or color.adjust instead.
darken subtracts a fixed lightness amount (20% lightness → 0% can become black). color.scale($c, $lightness: -30%) makes the color 30% darker than it was, which is usually what designers want.
No for modern spaces. Official docs require a legacy color space (rgb, hsl, or hwb). Convert first, or use color.scale / color.adjust with an explicit $space.
For the same fixed subtraction: color.adjust($color, $lightness: -$amount, $space: hsl) on Dart Sass 1.79+. For better relative darkening: color.scale($color, $lightness: -$amount).