Sass color.lightness()

Beginner
11 min read
Updated: Nov 2026
5 examples
Compiled CSS

Definition and Usage

color.lightness($color) returns the HSL lightness of a legacy color as a number between 0% and 100%. Global alias: lightness($color).

Official Sass docs mark it deprecated — prefer color.channel($color, "lightness") on Dart Sass 1.79+. Pair with color.hue() and color.saturation() when auditing a full HSL triple.

No longer recommended.

Because color.lightness() is redundant with color.channel(), migrate readers to the channel API in new code. Do not confuse this reader with the deprecated writer lighten().

Official samples.

color.lightness(#e1d7d2) → 85.2941176471%. #f2ece4 → 92.1568627451%. #dadbdf → 86.4705882353%.

Legacy colors only.

$color must be in a legacy space (rgb, hsl, or hwb). For modern spaces, use color.channel(..., $space: hsl).

Syntax

SCSS
@use "sass:color";

// Deprecated reader
color.lightness(#e1d7d2); // 85.2941176471%
color.lightness(#f2ece4); // 92.1568627451%
color.lightness(#dadbdf); // 86.4705882353%

// Prefer today (Dart Sass 1.79+)
color.channel(#e1d7d2, "lightness");
color.channel($c, "lightness", $space: hsl);

Pattern: recognize color.lightness in old files → rewrite with color.channel($c, "lightness").

Migrate to color.channel

Side-by-side mapping:

Legacy / currentPrefer (1.79+)
color.lightness($c)color.channel($c, "lightness")
lightness($c) (global)color.channel($c, "lightness")
color.hue($c) / color.saturation($c)color.channel($c, "hue") / "saturation"
Force HSL spacecolor.channel($c, "lightness", $space: hsl)

To change lightness, use writers like color.scale($c, $lightness: …) or color.adjust($c, $lightness: …, $space: hsl) — not the reader. Avoid new lighten() / darken() calls.

SCSS Examples

Examples use color.lightness(). Open View Compiled CSS for verified output (matches official Sass docs samples where noted).

Example 1 — Warm Hex Lightness (Official Docs)

A soft taupe hex reports lightness about 85.29%.

SCSS
@use "sass:color";

@debug color.lightness(#e1d7d2); // 85.2941176471%

.swatch {
  --lightness: #{color.lightness(#e1d7d2)};
}

How It Works

  1. Legacy hex is mapped into HSL.
  2. Lightness percent is about 85.29% (near-white band).
  3. Interpolation writes it into a custom property.
  4. Same read via color.channel(#e1d7d2, "lightness") on 1.79+.

Example 2 — Cream and Cool Grays (Official Docs)

Two more official samples: a very light cream and a cool gray.

SCSS
@use "sass:color";

@debug color.lightness(#f2ece4); // 92.1568627451%
@debug color.lightness(#dadbdf); // 86.4705882353%

.palette {
  --cream: #{color.lightness(#f2ece4)};
  --cool: #{color.lightness(#dadbdf)};
}

How It Works

  1. Both sit in the high-lightness band.
  2. Cream is brighter (~92%) than the cool gray (~86%).
  3. Useful when you sort surface tokens by brightness.
  4. Same idea after migrating to color.channel(..., "lightness").

Example 3 — White Is 100%, Black Is 0%

The ends of the HSL lightness scale.

SCSS
@use "sass:color";

.extremes {
  --white: #{color.lightness(white)};
  --black: #{color.lightness(black)};
}

How It Works

  1. White is full lightness 100%.
  2. Black is 0%.
  3. Landmarks help mixins decide if lighten risks white or darken risks black.
  4. On 1.79+, use color.channel for the same numbers.

Example 4 — Soft, Mid, and Deep Lightness

Read three familiar seeds used across lighten / darken tutorials.

SCSS
@use "sass:color";

.compare {
  --soft: #{color.lightness(#e1d7d2)};
  --mid: #{color.lightness(#6b717f)};
  --deep: #{color.lightness(#036)};
  --brand: #{color.lightness(#336699)};
}

How It Works

  1. Soft taupe ~85% — explains why lighten(#e1d7d2, 30%) becomes white.
  2. Deep navy at 20% — explains the darken(#036, 30%) black trap.
  3. Mid slate / brand sit in the middle band with more room to move.
  4. Read first, then choose scale / adjust safely.

Example 5 — Global lightness() with as *

Older stylesheets sometimes import the module into the current namespace.

SCSS
@use "sass:color" as *;

.panel {
  --lightness: #{lightness(#e1d7d2)};
}

How It Works

  1. as * brings members into the current scope.
  2. lightness() matches color.lightness().
  3. Result is still the official ~85.29%.
  4. Prefer namespaced color.lightness, then color.channel — not the writer lighten().

Edge Cases & Pitfalls

Most lightness-reader bugs are mixing it up with lighten(), modern spaces, or forgetting the % unit.

read

Readers do not lighten colors

color.lightness only returns a percent. To change brightness, use color.scale / color.adjust — not lighten() in new code.

name

lightness ≠ lighten

One reads a channel; the other is a deprecated writer that adds fixed lightness.

space

Legacy colors only for this helper

Official docs require rgb / hsl / hwb. Prefer color.channel(..., $space: hsl) for modern spaces.

migrate

Quote the channel name

Write color.channel($c, "lightness") with a quoted string.

Sass Support

color.lightness() remains for compatibility. New readers should use color.channel on Dart Sass 1.79+.

APIStatus
color.lightness() / lightness()Deprecated reader — still works on legacy colors
color.channel($c, "lightness")Preferred on Dart Sass 1.79+
LibSass / Ruby SassGlobal lightness() may exist — no modern module path
BrowsersN/A — only see compiled CSS values

Compile with the Dart Sass CLI.

Key Takeaways

  • Reads HSL lightness as a number from 0% to 100%.
  • Deprecated in favor of color.channel($c, "lightness").
  • Siblings: color.hue() and color.saturation().
  • Writers use scale / adjust — not this reader (and not new lighten).

One line: use color.lightness to understand old HSL reads — write new ones with color.channel.

Migrate Notes

Practical checklist:

migrate.txt
1. Find color.lightness($c) / lightness($c) in legacy SCSS
2. Require Dart Sass 1.79+ for color.channel
3. Replace with color.channel($c, "lightness")
4. Add $space: hsl when reading non-legacy colors
5. Use scale / adjust when you need to change lightness

Frequently Asked Questions

color.lightness($color) returns the HSL lightness of a legacy color as a number between 0% and 100%. Example: color.lightness(#e1d7d2) is about 85.29%; color.lightness(#f2ece4) is about 92.16%; color.lightness(#dadbdf) is about 86.47%.
Yes. Official Sass docs list it under Deprecated Functions and say it is no longer recommended because it is redundant with color.channel($color, "lightness").
A number from 0% to 100% (with the % unit). It is still a Sass number—meta.type-of reports number.
Official docs require a legacy color space (rgb, hsl, or hwb). Convert first, or use color.channel($color, "lightness", $space: hsl) on Dart Sass 1.79+.
color.hue(), color.saturation(), and color.lightness() are sibling deprecated readers for the three HSL channels. Prefer color.channel with "hue", "saturation", or "lightness" in new code.
color.lightness() only reads the lightness percent. lighten() is a separate deprecated global that increases lightness and returns a new color. Prefer color.channel to read and color.scale / color.adjust to change.
Replace color.lightness($color) with color.channel($color, "lightness") after @use "sass:color" on Dart Sass 1.79+. Keep color.lightness only when maintaining older compilers or legacy SCSS.

Next: Sass opacify()

Deprecated helper that increases alpha — prefer color.adjust / scale.

opacify() →

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.

8 people found this page helpful