Sass
CSS preprocessor

Sass darken() Function

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
Deprecated
Global · Dart Sass

What You’ll Learn

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

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.

  • darken(#b37399, 20%)#7c4465 (lightness 92% → 72%)
  • darken(#f2ece4, 40%)#b08b5a (lightness 85% → 45%)
  • darken(#036, 30%)black (lightness 20% → 0%)
💡
Beginner tip

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.

📝 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

ParameterTypeDescription
$colorColorMust be in a legacy color space (rgb, hsl, or hwb).
$amountNumber %How much to subtract from HSL lightness, between 0% and 100% (inclusive).

Return value

TypeMeaning
ColorA darker color (may clamp to black when lightness hits 0%).

📦 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.

📋 darken vs color.scale vs color.adjust

Official docs call out this trap with #036 (already only 20% lightness):

CallResultWhy
darken(#036, 30%)blackSubtracts 30% lightness from 20% → clamps to 0%
color.scale(#036, $lightness: -30%)#002447Moves 30% of the way toward minimum lightness
color.adjust(..., $lightness: -30%)Same fixed math as darkenUse only when you need identical legacy behavior

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS receives a finished color—no darken() call remains at runtime.

FeatureDart SassNotes
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 SassGlobal likelyLack modern module / $space APIs

⚡ Quick Reference

GoalCode
Darken 20% (legacy)darken(#b37399, 20%)#7c4465
Darken 40%darken(#f2ece4, 40%)#b08b5a
Overshoot trapdarken(#036, 30%)black
Relative darkencolor.scale(#036, $lightness: -30%)#002447
Same math as darkencolor.adjust($c, $lightness: -20%, $space: hsl)
Lighten twinlighten($c, $amount) (also deprecated)

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.

Example 1 — Lightness 92% → 72% (Official Docs)

A mauve brand darkens by a fixed 20% lightness.

styles.scss
// Lightness 92% becomes 72%.
@debug darken(#b37399, 20%); // #7c4465

.button {
  background: #b37399;
  &:hover {
    background: darken(#b37399, 20%);
  }
}

How It Works

Sass subtracts 20% from HSL lightness and emits a finished hex. Fine for light colors with room to spare—risky when the color is already dark.

Example 2 — Cream Darkened by 40% (Official Docs)

Lightness 85% becomes 45%.

styles.scss
// Lightness 85% becomes 45%.
@debug darken(#f2ece4, 40%); // #b08b5a

.card {
  --surface: #f2ece4;
  --shadow-tone: #{darken(#f2ece4, 40%)};
}

How It Works

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%);
}

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%)};
}

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.

styles.scss
@use "sass:color";

// Prefer on Dart Sass 1.79+:
// color.adjust($c, $lightness: -20%, $space: hsl)

.tokens {
  --legacy: #{darken(#b37399, 20%)};
  --adjust: #{color.adjust(#b37399, $lightness: -20%)};
  --brand: #{darken(#336699, 10%)};
}

How It Works

--legacy and --adjust match, so you can swap calls without visual diffs. Still consider scale when you redesign hover states.

🚀 Real-World Use Cases

  • Reading legacy SCSS — recognize darken() in older button/hover themes.
  • Safe migrations — swap to color.adjust for identical output, or scale for better UX.
  • Teaching HSL — show fixed lightness steps vs relative scaling.
  • Audit traps — find darken on already-dark brands that collapse to black.
  • Pairing with lighten — both globals are deprecated twins; migrate together.

🧠 How Compilation Works

1

Write SCSS

Call darken($c, 20%) or migrate to scale / adjust.

Source
2

Read HSL lightness

Sass works in HSL for this legacy helper on rgb/hsl/hwb colors.

HSL
3

Subtract $amount

Lightness drops by a fixed percent; may clamp at 0%.

Darken
4

Finished CSS color

Browsers see hex / named black—not a Sass function call.

⚠️ Common Pitfalls

  • Using it in new code — prefer color.scale (or adjust for same math).
  • Expecting color.darken() — that name does not exist in sass:color.
  • Dark colors + large amounts — easy to clamp to black unexpectedly.
  • Modern color spaces$color must be legacy for global darken.
  • Assuming “30% darker” means scaledarken is fixed subtraction, not relative.

💡 Best Practices

✅ Do

  • Use color.scale($c, $lightness: -$n) for relative darkening
  • Use color.adjust(..., $lightness: -$n, $space: hsl) when matching old darken
  • Audit already-dark brands before applying large amounts
  • Migrate lighten siblings in the same pass
  • Document hover/token recipes with the modern API

❌ Don’t

  • Add new darken() calls in greenfield projects
  • Look for color.darken in the module
  • Pass modern oklch colors into global darken
  • Expect the browser to re-run Sass at runtime
  • Assume fixed lightness steps feel “30% darker”

Key Takeaways

Knowledge Unlocked

Five things to remember about darken()

Deprecated fixed lightness subtractor—prefer scale.

5
Core concepts
⚠️ 02

Status

Deprecated

Docs
🎨 03

Does

subtract lightness

Fixed
📦 04

Module?

No color.darken

Global
05

Replace

scale or adjust

Migrate

❓ 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).
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.

Conclusion

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.

Continue with desaturate(), color.scale(), or color.adjust().

Next: desaturate()

You learned deprecated darken()—next is the deprecated global desaturator.

desaturate() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful