Sass
CSS preprocessor

Sass color.scale() Function

Beginner
⏱️ 14 min read
📚 Updated: Jul 2026
🎯 5 Examples
sass:color · Dart Sass

What You’ll Learn

color.scale() belongs to the built-in sass:color module. It fluidly scales one or more color channels toward their maximum or minimum by a percentage of the remaining room. This page covers how percentages work, how scale differs from adjust and change, optional $space (Dart Sass 1.79+), and five compiled examples.

01

Concept

Fluid scaling

02

Module

@use "sass:color"

03

Range

-100% … 100%

04

Vs

adjust & change

05

Space

Optional (1.79+)

06

Practice

5 examples

What Is color.scale()?

Scale means “slide this dial a percentage of the way toward its end stop.” Official docs: each keyword argument between -100% and 100% moves a property from its current position toward the maximum (positive) or minimum (negative). So $lightness: 50% makes colors 50% closer to maximum lightness without jumping all the way to white.

  • color.scale(#6b717f, $red: 15%)#81717f (docs also show rgb(129.2, 113, 127))
  • color.scale(#d2e1dd, $lightness: -10%, $alpha: -50%)rgba(184, 208, 201, 0.5)
  • color.scale(#998099, $whiteness: 100%, $blackness: -50%)#d5d5d5
💡
Beginner tip

Think of a volume slider: 50% is not “add 50,” it is “go halfway from here to the top.” Dark colors still have lots of room to lighten; already-light colors move less before they hit white.

📝 Syntax

Load the color module, then pass a color plus keyword channel percentages:

styles.scss
@use "sass:color";

color.scale($color,
  $red: null, $green: null, $blue: null,
  $saturation: null, $lightness: null,
  $whiteness: null, $blackness: null,
  $x: null, $y: null, $z: null,
  $chroma: null,
  $alpha: null,
  $space: null)
// Global alias:
// scale-color(...)

Common parameters

ParameterTypeDescription
$colorColorThe starting color to scale (required).
$red / $green / $bluePercentageScale RGB channels toward their max/min (-100%–100%).
$saturation / $lightnessPercentageScale HSL saturation or lightness toward their bounds.
$whiteness / $blacknessPercentageScale HWB channels (Dart Sass 1.28+).
$chroma / $x / $y / $zPercentageModern space channels (Dart Sass 1.79+).
$alphaPercentageScale opacity toward fully opaque or fully transparent.
$spaceColor space nameScale channels in another space (Dart Sass 1.79+), e.g. oklch. Result still returns in $color’s space.

Return value

TypeMeaning
ColorA new color in the same space as $color, with the requested fluid scales applied.

📦 Loading sass:color

Prefer the module API. Official docs also document the global name scale-color() for older stylesheets.

styles.scss
// Recommended — namespaced
@use "sass:color";
$c: color.scale(#6b717f, $red: 15%);

// Optional — bring members into the current namespace
@use "sass:color" as *;
$c: scale(#6b717f, $red: 15%);

// Optional — custom namespace
@use "sass:color" as c;
$c: c.scale(#6b717f, $red: 15%);

// Legacy global name
$c: scale-color(#6b717f, $red: 15%);
⚠️
Put @use first

Keep @use "sass:color"; near the top of the file. Built-in modules need Dart Sass (about 1.23+). Passing $space, $chroma, or xyz channels needs 1.79+.

⚖️ How Fluid Scaling Works

Official docs: each percentage says how far to move from the current value toward the channel’s maximum (positive) or minimum (negative).

ArgumentMeaning
$lightness: 100%Go all the way to maximum lightness
$lightness: 50%Move halfway from current lightness toward maximum
$lightness: 0%No change
$lightness: -50%Move halfway toward minimum lightness
⚠️
Heads up from the docs

For legacy colors, do not mix RGB channels with HSL channels in one call, or either of those with HWB channels—Sass errors. Even so, official guidance: pass $space explicitly once you are on Dart Sass 1.79+.

📋 scale vs adjust vs change

Official docs point to these three siblings for different jobs.

HelperWhat it doesMental model
color.scale()Scale toward a bound by a %“Move 20% of the way lighter”
color.adjust()Add/subtract fixed amounts“Plus 10% lightness”
color.change()Set channels to exact values“Make lightness exactly 70%”

🛠 Compatibility

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

FeatureDart SassNotes
@use "sass:color" / color.scale1.23+Preferred module API
$whiteness / $blackness1.28+HWB channel scaling
$space, $chroma, $x/$y/$z1.79+Modern color-space scaling
Global scale-color()Long-standingPrefer module form in new SCSS
LibSass / Ruby SassNo modern module APIMay expose scale-color(); prefer Dart Sass

⚡ Quick Reference

GoalCode
Import color@use "sass:color";
Scale red toward maxcolor.scale(#6b717f, $red: 15%)
Lighten fluidlycolor.scale($c, $lightness: 20%)
Darken fluidlycolor.scale($c, $lightness: -25%)
Fade alphacolor.scale($c, $alpha: -40%)
Scale in oklch (1.79+)color.scale($c, $lightness: -10%, $space: oklch)
Legacy globalscale-color(#6b717f, $red: 15%)

Examples Gallery

Examples 1–3 and 5 compile on everyday Dart Sass. Example 4 shows official $space / chroma results for Dart Sass 1.79+. Open View Compiled CSS to inspect the output.

📚 Getting Started

Scale a single channel, then combine lightness and alpha.

Example 1 — Scale the Red Channel

Move red 15% of the way toward its maximum (classic docs sample).

styles.scss
@use "sass:color";

@debug color.scale(#6b717f, $red: 15%); // #81717f (docs: rgb(129.2, 113, 127))

.swatch {
  color: color.scale(#6b717f, $red: 15%);
}

How It Works

Red slides partway toward its maximum while green and blue stay put. Newer Dart Sass may emit rgb(129.2, 113, 127)—same paint as #81717f.

Example 2 — Scale Lightness and Alpha Together

Darken a mint slightly and cut opacity in one call.

styles.scss
@use "sass:color";

.overlay {
  background: color.scale(#d2e1dd, $lightness: -10%, $alpha: -50%);
}

.washed {
  color: color.scale(#998099, $whiteness: 100%, $blackness: -50%);
}

How It Works

Lightness moves 10% toward minimum; alpha moves 50% toward fully transparent. The HWB example pushes whiteness up and blackness down for a washed gray.

📈 Practical Patterns

Sibling helpers, modern $space, and brand token ladders.

Example 3 — Scale vs Adjust vs Change

Same starting color, three different “make it lighter” tools.

styles.scss
@use "sass:color";

$c: #6b717f;

.compare {
  --scale-20: #{color.scale($c, $lightness: 20%)};
  --adjust-20: #{color.adjust($c, $lightness: 20%)};
  --change-70: #{color.change($c, $lightness: 70%)};
}

How It Works

scale moves 20% of the remaining room toward max lightness. adjust adds a fixed 20% lightness. change jumps to absolute 70% lightness. Three different midtones from one seed.

Example 4 — Scale in Another Space (Dart Sass 1.79+)

Official docs samples using $space and chroma.

styles.scss
@use "sass:color";

// Requires Dart Sass 1.79+
@debug color.scale(#d2e1dd, $lightness: -10%, $space: oklch);
@debug color.scale(oklch(80% 20% 120deg), $chroma: 50%, $alpha: -40%);

.modern {
  --oklch-lightness: #{color.scale(#d2e1dd, $lightness: -10%, $space: oklch)};
  color: color.scale(oklch(80% 20% 120deg), $chroma: 50%, $alpha: -40%);
}

How It Works

Scaling lightness in oklch uses perceptual lightness, then returns a color in the original space of $color. Chroma 50% moves halfway toward max chroma; alpha -40% fades toward transparent.

Example 5 — Brand Token Ladder + Global Alias

Build hover-ready steps from one brand hex; module and global names match.

styles.scss
@use "sass:color";

$brand: #336699;

.card {
  background: $brand;
  color: color.scale($brand, $lightness: 40%);
  border-color: color.scale($brand, $lightness: -25%);
  outline-color: color.scale($brand, $saturation: -30%);
  --soft: #{color.scale($brand, $alpha: -40%)};
}

.names {
  --module: #{color.scale(#6b717f, $red: 15%)};
  --global: #{scale-color(#6b717f, $red: 15%)};
}

How It Works

One brand seed becomes text, border, muted outline, and a soft translucent twin. Module color.scale and global scale-color emit the same hex.

🚀 Real-World Use Cases

  • Hover / active states — fluidly lighten or darken without hardcoding new hexes.
  • Soft borders — scale saturation or lightness toward a quieter twin.
  • Overlay fades — scale alpha toward transparent for chips and sheets.
  • Token ladders — generate related steps that stay proportional on light and dark seeds.
  • Perceptual tweaks — use $space: oklch on Dart Sass 1.79+.
  • Teaching color math — contrast scale vs adjust vs change side by side.

🧠 How Compilation Works

1

Write SCSS

Call color.scale($color, ...) after @use.

Source
2

Pick a space

Use $space (1.79+) or scale in $color’s own space.

Space
3

Fluid move

Slide each channel a % of the remaining room toward min/max.

Scale
4

Plain CSS color ships

Browsers receive hex/rgb/oklch—not a Sass call.

⚠️ Common Pitfalls

  • Treating % like adjust$lightness: 20% is not the same as adjust(..., $lightness: 20%).
  • Mixing RGB + HSL keywords — on legacy colors Sass errors if you combine those families (or with HWB) in one call.
  • Using $space on older Dart Sass — needs 1.79+; bare channel scales still work earlier.
  • Expecting full white from 50%50% only moves halfway toward maximum lightness.
  • Forgetting units — scale arguments are percentages such as 15%, not bare 15.

💡 Best Practices

✅ Do

  • Use @use "sass:color" and color.scale() in new SCSS
  • Prefer scale when relative, proportional shifts look more natural
  • Pass $space explicitly on Dart Sass 1.79+
  • Keep one channel family per call on legacy colors
  • Check contrast after lightening interactive text

❌ Don’t

  • Expect the browser to re-run color.scale
  • Confuse scale percentages with adjust amounts
  • Mix RGB and HSL keywords in one legacy call
  • Rely on LibSass for sass:color
  • Skip accessibility checks on scaled UI colors

Key Takeaways

Knowledge Unlocked

Five things to remember about color.scale()

Fluid % moves toward min/max—not the same as adjust.

5
Core concepts
📦 02

Module

sass:color

@use
🎨 03

Does

fluid channel scale

Scale
04

Range

-100% … 100%

Bounds
05

Unlike

adjust / change

Siblings

❓ Frequently Asked Questions

color.scale($color, ...) fluidly scales one or more channel properties toward their maximum or minimum by a percentage. Example: color.scale(#6b717f, $red: 15%) moves red 15% of the way toward its maximum.
scale moves a percentage of the remaining room toward a bound. adjust adds or subtracts fixed amounts. change sets channels to absolute new values.
Each keyword argument must be a number between -100% and 100% (inclusive). Positive values move toward the channel maximum; negative values move toward the minimum.
Add @use "sass:color"; then call color.scale($brand, $lightness: 20%) or other channel keywords. Prefer the module form. The global alias is scale-color().
On Dart Sass 1.79+, $space lets you scale channels in another color space (for example oklch) while still returning a color in $color’s original space.
The module form needs Dart Sass with @use (about 1.23+). $whiteness/$blackness need 1.28+. $space, $chroma, and xyz channels need 1.79+. LibSass/Ruby Sass may expose scale-color() but lack the modern module API.
Did you know?

Official Sass docs emphasize that $lightness: 50% never forces every color to the same mid gray—it only moves each color halfway from its own lightness toward maximum. That is why scale often looks more natural than a fixed adjust on mixed light and dark brand tokens.

Conclusion

color.scale() is the clearest way to ask Sass for proportional channel moves. Use percentages toward min/max, keep adjust for fixed amounts, change for absolute values, and pass $space on Dart Sass 1.79+ when perceptual spaces matter.

Continue with color.space(), color.adjust(), or the CSS introduction.

Explore color.space() Next

Read a color’s space name with the sass:color module (Dart Sass 1.79+).

Sass color.space() →

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