Sass
CSS preprocessor

Sass color.lightness() Function

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

What You’ll Learn

color.lightness() belongs to the built-in sass:color module (Deprecated Functions). It returns a legacy color’s HSL lightness as a number from 0% to 100% at compile time. This page covers the brightness dial, siblings hue / saturation, migration to color.channel(), and five compiled examples.

01

Concept

HSL lightness 0%–100%

02

Status

Deprecated

03

Siblings

hue() / saturation()

04

Legacy only

rgb / hsl / hwb

05

Migrate

color.channel()

06

Practice

5 examples

What Is color.lightness()?

Lightness is how bright a color looks on the HSL scale—from black (0%) through midtones to white (100%). Official docs: color.lightness() returns that percent as a number between 0% and 100%. It only reads the value; it does not lighten the color.

  • color.lightness(#e1d7d2)85.2941176471%
  • color.lightness(#f2ece4)92.1568627451%
  • color.lightness(#dadbdf)86.4705882353%
💡
Beginner tip

Think of HSL as three dials: hue (angle), saturation (how vivid), and lightness (how bright). color.lightness turns only the brightness dial into a number you can store, compare, or log—handy before calling lighten() or darken() in legacy code.

📝 Syntax

Load the color module, then pass a legacy color:

styles.scss
@use "sass:color";

// Deprecated — still works on legacy colors
color.lightness($color)

// Optional — bring members into scope
@use "sass:color" as *;
lightness($color)

// Recommended migration (Dart Sass 1.79+)
color.channel($color, "lightness")

Parameters

ParameterTypeDescription
$colorColorMust be in a legacy color space (rgb, hsl, or hwb).

Return value

TypeMeaning
Number (with %)HSL lightness from 0% to 100%.

📦 Loading sass:color & Migrating

Prefer the namespaced form. Bare lightness() only works after @use "sass:color" as *;—otherwise CSS may keep the call as a plain string.

styles.scss
@use "sass:color";

// Old (deprecated, still available)
$l: color.lightness(#e1d7d2); // 85.2941176471%

// New — preferred on Dart Sass 1.79+
$l: color.channel(#e1d7d2, "lightness");

// Optional global-style import
@use "sass:color" as *;
$l: lightness(#e1d7d2);
⚠️
Version note for color.channel

color.channel() needs Dart Sass 1.79+. On older compilers, keep color.lightness() until you can upgrade—then migrate.

🎨 HSL Trio: Hue, Saturation, Lightness

Official docs also list color.hue() and color.saturation() the same way (deprecated readers for the other two HSL channels). Together they rebuild the classic hsl(h, s, l) triple from any legacy color.

  • Lightness 0% → black (no brightness)
  • Lightness near 50% → midtones with clear hue
  • Lightness 100% → white (full brightness)
💡
Writing lightness instead of reading

To raise or lower lightness, use color.adjust(), color.scale(), or the deprecated globals lighten() / darken()—not color.lightness(), which only returns a number.

📋 color.lightness vs color.channel

HelperJobStatus
color.lightness()Read HSL lightness on legacy colorsDeprecated / not recommended
color.channel($c, "lightness")Same read (and any other channel)Preferred on Dart Sass 1.79+
color.scale(..., $lightness: …)Relative lighten / darkenWriter, not a reader

🛠 Compatibility

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

FeatureDart SassNotes
color.lightness() / lightness()Yes (deprecated)Legacy colors only
Siblings hue() / saturation()Yes (deprecated)Same pattern for the other HSL channels
color.channel(…, "lightness")1.79+Official recommended replacement
LibSass / Ruby SassGlobals likelyMay lack modern @use / channel

⚡ Quick Reference

GoalCode
Warm taupecolor.lightness(#e1d7d2)85.2941176471%
Creamcolor.lightness(#f2ece4)92.1568627451%
Cool graycolor.lightness(#dadbdf)86.4705882353%
Brand hexcolor.lightness(#336699)40%
Modern readcolor.channel($c, "lightness")
Change lightnesscolor.scale($c, $lightness: 15%)

Examples Gallery

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

📚 Getting Started

Official docs samples for soft, cream, and cool surfaces.

Example 1 — Warm Hex Lightness (Official Docs)

A soft taupe hex reports lightness about 85.29%.

styles.scss
@use "sass:color";

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

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

How It Works

Sass maps the legacy hex into HSL, reads the lightness percent, and writes that number (with %) into a custom property.

Example 2 — Cream and Cool Grays (Official Docs)

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

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

Both sit in the high-lightness band. Cream is brighter (~92%) than the cool gray (~86%)—useful when you sort surface tokens by brightness.

📈 Practical Patterns

Extremes, soft vs deep compares, and the global alias.

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

The ends of the HSL lightness scale.

styles.scss
@use "sass:color";

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

How It Works

These landmarks make mixins easier: compare a brand lightness to decide if lighten risks white or darken risks black.

Example 4 — Soft, Mid, and Deep Lightness

Read three familiar seeds used across lighten / darken tutorials.

styles.scss
@use "sass:color";

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

How It Works

Soft taupe is already near white—that is why lighten(#e1d7d2, 30%) becomes white. Deep navy at 20% explains the darken(#036, 30%) black trap. Reading lightness first avoids surprises.

Example 5 — Global lightness() with as *

Older stylesheets sometimes import the module into the current namespace.

styles.scss
@use "sass:color" as *;

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

How It Works

With as *, lightness() matches color.lightness(). Prefer the namespaced form (then color.channel) when you modernize the file. Do not confuse this reader with the deprecated global lighten() writer.

🚀 Real-World Use Cases

  • Reading legacy SCSS — recognize color.lightness in older HSL workflows.
  • Safe migrations — replace with color.channel($c, "lightness") on Dart Sass 1.79+.
  • Token audits — sort surfaces by brightness before lighten / darken.
  • Conditional mixins — pick text color when lightness is above or below 50%.
  • Teaching HSL — show why pale colors clamp to white under fixed lighten.

🧠 How Compilation Works

1

Write SCSS

Call color.lightness($c) or migrate to color.channel.

Source
2

Map to HSL

Sass views the legacy color in hue / saturation / lightness.

HSL
3

Read lightness

You get a number from 0% to 100%.

Number
4

CSS sees the number

Custom properties get finished values—not a Sass call.

⚠️ Common Pitfalls

  • Using it in new code — prefer color.channel($c, "lightness").
  • Confusing with lighten()lightness reads; lighten writes a new color.
  • Bare lightness() without as * — may compile as a CSS function string.
  • Modern color spaces$color must be legacy for color.lightness.
  • Expecting a color back — this helper reads a percent; use scale/adjust to change.

💡 Best Practices

✅ Do

  • Migrate to color.channel($c, "lightness") on Dart Sass 1.79+
  • Use @use "sass:color" and namespaced color.lightness()
  • Pair with hue/saturation when auditing full HSL
  • Read lightness before large lighten / darken amounts
  • Document intentional brand brightness on the scale

❌ Don’t

  • Add new color.lightness() calls in greenfield projects
  • Pass modern oklch colors into color.lightness
  • Call bare lightness() without importing the module
  • Expect the browser to re-run Sass at runtime
  • Use a reader when you meant lighten() or color.scale

Key Takeaways

Knowledge Unlocked

Five things to remember about color.lightness()

Deprecated HSL lightness reader—migrate to color.channel.

5
Core concepts
⚠️ 02

Status

Deprecated

Docs
🌞 03

Returns

0% … 100%

HSL
🔄 04

Siblings

hue() / saturation()

Trio
05

Replace

channel(..., "lightness")

Migrate

❓ 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.
Did you know?

Official Sass docs keep dedicated HSL readers like color.lightness() for compatibility, but the modern story is one API: color.channel($c, "lightness")—the same pattern you use for hue, saturation, red, green, and more.

Conclusion

color.lightness() reads a legacy color’s HSL lightness as a number from 0% to 100%. Treat it as deprecated documentation: prefer color.channel($color, "lightness") for new SCSS on Dart Sass 1.79+.

Continue with opacify(), color.channel(), or color.scale().

Next: opacify()

You learned deprecated color.lightness()—next, raise alpha with opacify().

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.

5 people found this page helpful