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
Concept
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.
Foundation
📝 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
Parameter
Type
Description
$color
Color
Must be in a legacy color space (rgb, hsl, or hwb).
Return value
Type
Meaning
Number (with %)
HSL lightness from 0% to 100%.
Modules
📦 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.
Details
🎨 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.
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)};
}
📤 Compiled CSS:
.panel {
--lightness: 85.2941176471%;
}
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.
Applications
🚀 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.
Watch Out
⚠️ 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.
Pro Tips
💡 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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.lightness()
Deprecated HSL lightness reader—migrate to color.channel.
5
Core concepts
📝01
Call
color.lightness($c)
API
⚠️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.
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+.