darken() is a global Sass helper documented in the sass:color module page (Deprecated Functions). It makes a legacy color darker by decreasing HSL lightness by $amount at compile time. This page covers the fixed-amount trap, why the module system skipped it, how it differs from color.scale(), migration to color.adjust(), and five compiled examples.
01
Concept
Subtract HSL lightness
02
Status
Deprecated global
03
$amount
0% … 100%
04
Prefer
color.scale()
05
Same math
color.adjust()
06
Practice
5 examples
Concept
What Is darken()?
Darken means “push this color toward black by lowering lightness.” Official docs: it decreases the HSL lightness of $color by $amount (0%–100%). Hue and saturation stay related; only lightness moves down by a fixed chunk.
Fixed subtraction is like taking 30 steps down a staircase no matter how tall you are. A short color (already dark) can hit the floor (black). Relative scaling is like “go 30% of the way toward black from where you stand”—that is color.scale.
Foundation
📝 Syntax
Call the global function with a legacy color and a percentage:
styles.scss
// Deprecated global (legacy colors only)
darken($color, $amount)
// Preferred — relative darkening
@use "sass:color";
color.scale($color, $lightness: -$amount)
// Same fixed math as darken (Dart Sass 1.79+ with $space)
color.adjust($color, $lightness: -$amount, $space: hsl)
Parameters
Parameter
Type
Description
$color
Color
Must be in a legacy color space (rgb, hsl, or hwb).
$amount
Number %
How much to subtract from HSL lightness, between 0% and 100% (inclusive).
Return value
Type
Meaning
Color
A darker color (may clamp to black when lightness hits 0%).
Modules
📦 Why There Is No color.darken()
Official docs: because darken() is usually not the best way to make a color darker, it is not included in the new module system. You will not find color.darken after @use "sass:color".
styles.scss
// Old (deprecated global)
$hover: darken(#b37399, 20%);
@use "sass:color";
// Same fixed subtraction as darken
$hover: color.adjust(#b37399, $lightness: -20%); // works on older Dart Sass too
// Official form (Dart Sass 1.79+):
// color.adjust(#b37399, $lightness: -20%, $space: hsl)
// Usually better — 20% darker relative to the original
$hover: color.scale(#b37399, $lightness: -20%);
⚠️
Version note for $space
Official migration uses $space: hsl, which needs Dart Sass 1.79+. On older compilers, color.adjust($c, $lightness: -$amount) still matches darken for typical hex/RGB colors.
Compare
📋 darken vs color.scale vs color.adjust
Official docs call out this trap with #036 (already only 20% lightness):
Call
Result
Why
darken(#036, 30%)
black
Subtracts 30% lightness from 20% → clamps to 0%
color.scale(#036, $lightness: -30%)
#002447
Moves 30% of the way toward minimum lightness
color.adjust(..., $lightness: -30%)
Same fixed math as darken
Use only when you need identical legacy behavior
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a finished color—no darken() call remains at runtime.
Feature
Dart Sass
Notes
Global darken()
Yes (deprecated)
Legacy colors only; omitted from sass:color
color.scale($lightness: …)
Yes (module)
Preferred relative darkening
color.adjust(..., $space: hsl)
1.79+
Official same-math migration form
LibSass / Ruby Sass
Global likely
Lack modern module / $space APIs
Cheat Sheet
⚡ Quick Reference
Goal
Code
Darken 20% (legacy)
darken(#b37399, 20%) → #7c4465
Darken 40%
darken(#f2ece4, 40%) → #b08b5a
Overshoot trap
darken(#036, 30%) → black
Relative darken
color.scale(#036, $lightness: -30%) → #002447
Same math as darken
color.adjust($c, $lightness: -20%, $space: hsl)
Lighten twin
lighten($c, $amount) (also deprecated)
Hands-On
Examples Gallery
Examples use deprecated global darken() plus modern scale / adjust migrations. Open View Compiled CSS for verified output (matches official Sass docs samples).
📚 Getting Started
Official docs samples for everyday darken amounts.
A large fixed step turns a near-white cream into a muted brown. In new code, try color.scale(#f2ece4, $lightness: -40%) and compare the look.
📈 Practical Patterns
The black trap, preferred scale, and adjust migration.
Example 3 — Dark Color + Large Amount → Black (Official Docs)
Lightness 20% minus 30% clamps to black.
styles.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
This is the classic reason official docs discourage darken. You asked for “a bit darker,” but fixed math wiped the color out.
Example 4 — Prefer color.scale() (Official Docs)
Same seed color, relative 30% darkening keeps a visible navy.
styles.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: darken collapses to black; scale keeps a usable dark blue. Prefer scale in new SCSS.
Example 5 — Preserve Old Math with color.adjust()
Match darken(#b37399, 20%) exactly when migrating.
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).
Did you know?
Official Sass docs skip darken() in the module system on purpose: relative tools like color.scale() darken more predictably across light and dark seeds, so a fixed-lightness global became a legacy footgun rather than a best practice.
darken() is the classic global way to subtract HSL lightness on legacy colors. Treat it as deprecated documentation: prefer color.scale($color, $lightness: -$amount) for relative darkening, or color.adjust when you need identical old math.