color.whiteness() belongs to the built-in sass:color module (Deprecated Functions). It returns a legacy color’s HWB whiteness as a percentage from 0% to 100% at compile time. This page covers the HWB idea, the legacy-color rule, Dart Sass 1.28+ support, migration to color.channel(), and five compiled examples.
01
Concept
HWB whiteness %
02
Status
Deprecated
03
Range
0% … 100%
04
Needs
Dart Sass 1.28+
05
Migrate
color.channel()
06
Practice
5 examples
Concept
What Is color.whiteness()?
Whiteness is the “how much white paint?” channel in the HWB (Hue–Whiteness–Blackness) model. Official docs: color.whiteness() returns that channel as a number between 0% and 100%. Pure black has 0% whiteness; pure white has 100%.
color.whiteness(#e1d7d2) → 82.3529411765%
color.whiteness(white) → 100%
color.whiteness(black) → 0%
💡
Beginner tip
Picture mixing a pure hue with white paint and black paint. Whiteness lightens; blackness darkens. color.whiteness only reads the white mix as a percentage—it does not lighten the color. To change whiteness, use color.adjust() or color.change() with $whiteness.
Foundation
📝 Syntax
Load the color module, then pass a legacy color:
styles.scss
@use "sass:color";
// Deprecated — Dart Sass 1.28+
color.whiteness($color)
// Optional — bring members into scope
@use "sass:color" as *;
whiteness($color)
// Recommended migration (Dart Sass 1.79+)
color.channel($color, "whiteness")
Parameters
Parameter
Type
Description
$color
Color
Must be in a legacy color space (rgb, hsl, or hwb).
Return value
Type
Meaning
Number with %
HWB whiteness from 0% to 100%.
Modules
📦 Loading sass:color & Migrating
Prefer the namespaced form. Bare whiteness() only works after @use "sass:color" as *;—otherwise CSS may keep the call as a plain string.
styles.scss
@use "sass:color";
// Old (deprecated, Dart Sass 1.28+)
$w: color.whiteness(#e1d7d2); // 82.3529411765%
// New — preferred on Dart Sass 1.79+
$w: color.channel(#e1d7d2, "whiteness");
// Optional global-style import
@use "sass:color" as *;
$w: whiteness(#e1d7d2);
⚠️
Version notes
color.whiteness() needs Dart Sass 1.28+. color.channel() needs 1.79+. On 1.28–1.78, keep color.whiteness until you can upgrade.
Details
🎨 HWB: Whiteness + Blackness
HWB describes a color as a hue mixed with white and black. For many everyday hex colors, whiteness and blackness percentages add up to less than 100%—the rest is the pure hue.
Whiteness high → lighter, chalkier look
Whiteness 0% → no white mix (black is the extreme opposite case)
Whiteness 100% → pure white
💡
Sibling channel
Official docs also document color.blackness() the same way (also deprecated in favor of color.channel($c, "blackness")). Reading both helps you understand an HWB breakdown of a brand hex.
Compare
📋 color.whiteness vs color.channel
Helper
Job
Status
color.whiteness()
Read HWB whiteness on legacy colors
Deprecated / not recommended
color.channel($c, "whiteness")
Same read (and any other channel)
Preferred on Dart Sass 1.79+
color.adjust(..., $whiteness: …)
Change whiteness by a fixed amount
Writer, not a reader
Compare
🔍 Whiteness vs HSL Lightness
Beginners often mix up HWB whiteness with HSL lightness. They are related ideas, but different models:
HWB whiteness
HSL lightness
Model
Hue + white mix + black mix
Hue + saturation + lightness
Reader (deprecated)
color.whiteness()
color.lightness()
Modern read
color.channel($c, "whiteness")
color.channel($c, "lightness")
Mental picture
How much white paint is mixed in?
Where is the color on dark…light?
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a finished percentage—no color.whiteness() call remains at runtime.
Feature
Dart Sass
Notes
color.whiteness()
1.28+ (deprecated)
Legacy colors only; LibSass / Ruby Sass ✗
color.channel(…, "whiteness")
1.79+
Official recommended replacement
Related $whiteness on adjust/change/scale
1.28+
Writers for the same HWB channel
Cheat Sheet
⚡ Quick Reference
Goal
Code
Warm grey hex
color.whiteness(#e1d7d2) → 82.3529411765%
White
color.whiteness(white) → 100%
Black
color.whiteness(black) → 0%
Brand blue
color.whiteness(#336699) → 20%
Modern read
color.channel($c, "whiteness")
Change whiteness
color.adjust($c, $whiteness: 10%)
Hands-On
Examples Gallery
Examples use color.whiteness() on Dart Sass 1.28+. Open View Compiled CSS for verified output (matches official Sass docs samples where noted).
📚 Getting Started
Official docs samples for everyday and extreme colors.
Example 1 — Warm Hex Whiteness (Official Docs)
A soft taupe hex reports a high whiteness percentage.
Whiteness dominates this soft tone; blackness is small; their sum stays under 100%, leaving room for the hue. Both readers are deprecated—migrate to color.channel with "whiteness" / "blackness".
Example 5 — Branch on High Whiteness
Use the percentage in a simple token report for a soft taupe.
Because whiteness is a percentage number, you can compare it in Sass. On Dart Sass 1.79+, swap to color.channel($tone, "whiteness") and keep the same if() logic.
Applications
🚀 Real-World Use Cases
Reading legacy SCSS — recognize color.whiteness in older HWB workflows.
Safe migrations — replace with color.channel($c, "whiteness") on Dart Sass 1.79+.
Token audits — flag colors that sit too far toward chalky white.
HWB teaching — pair with blackness to explain the model.
Conditional mixins — pick dark text when whiteness is high.
🧠 How Compilation Works
1
Write SCSS
Call color.whiteness($c) or migrate to color.channel.
Source
2
Map to HWB
Sass views the legacy color in Hue–Whiteness–Blackness.
HWB
3
Read whiteness
You get a percentage from 0% to 100%.
Percent
4
✓
CSS sees the %
Custom properties get finished percentages—not a Sass call.
Watch Out
⚠️ Common Pitfalls
Using it in new code — prefer color.channel($c, "whiteness").
Bare whiteness() without as * — may compile as a CSS function string.
Modern color spaces — $color must be legacy for color.whiteness.
Confusing with HSL lightness — different models; use the matching channel reader.
Expecting a color back — this helper reads a percentage; use adjust/change to write.
Pro Tips
💡 Best Practices
✅ Do
Migrate to color.channel($c, "whiteness") on Dart Sass 1.79+
Use @use "sass:color" and color.whiteness() on 1.28+
Pair with blackness when explaining HWB
Compare percentages in mixins for token rules
Document when a brand is intentionally pale
❌ Don’t
Add new color.whiteness() calls in greenfield projects
Pass modern oklch colors into color.whiteness
Call bare whiteness() without importing the module
Expect the browser to re-run Sass at runtime
Use a reader when you meant to change whiteness
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.whiteness()
Deprecated HWB whiteness reader—migrate to color.channel.
5
Core concepts
📝01
Call
color.whiteness($c)
API
⚠️02
Status
Deprecated
Docs
🎨03
Returns
0% … 100%
HWB
⚡04
Needs
Dart Sass 1.28+
Version
✓05
Replace
channel(..., "whiteness")
Migrate
❓ Frequently Asked Questions
color.whiteness($color) returns the HWB whiteness of a legacy color as a percentage between 0% and 100%. Example: color.whiteness(white) is 100%; color.whiteness(black) is 0%.
Yes. Official Sass docs list it under Deprecated Functions and say it is no longer recommended because it is redundant with color.channel($color, "whiteness").
In the HWB (Hue-Whiteness-Blackness) model, whiteness is how much white is mixed into the pure hue. Higher whiteness means a lighter, chalkier color.
Official docs: Dart Sass since 1.28.0. LibSass and Ruby Sass are not supported for this helper.
Official docs require a legacy color space (rgb, hsl, or hwb). Convert first, or use color.channel($color, "whiteness", $space: hwb) on Dart Sass 1.79+.
Replace color.whiteness($color) with color.channel($color, "whiteness") after @use "sass:color" on Dart Sass 1.79+. Keep color.whiteness on older 1.28–1.78 compilers until you upgrade.
Did you know?
Official Sass docs keep dedicated readers like color.whiteness() for compatibility, but the modern story is one API: color.channel($c, "whiteness") (and the same pattern for blackness, hue, alpha, and more).
color.whiteness() reads a legacy color’s HWB whiteness as a percentage from 0% to 100% (Dart Sass 1.28+). Treat it as deprecated documentation: prefer color.channel($color, "whiteness") for new SCSS on Dart Sass 1.79+.