Sass color.whiteness() Function

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

What You’ll Learn

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

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.

📝 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

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

Return value

TypeMeaning
Number with %HWB whiteness from 0% to 100%.

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

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

📋 color.whiteness vs color.channel

HelperJobStatus
color.whiteness()Read HWB whiteness on legacy colorsDeprecated / 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 amountWriter, not a reader

🔍 Whiteness vs HSL Lightness

Beginners often mix up HWB whiteness with HSL lightness. They are related ideas, but different models:

HWB whitenessHSL lightness
ModelHue + white mix + black mixHue + saturation + lightness
Reader (deprecated)color.whiteness()color.lightness()
Modern readcolor.channel($c, "whiteness")color.channel($c, "lightness")
Mental pictureHow much white paint is mixed in?Where is the color on dark…light?

🛠 Compatibility

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

FeatureDart SassNotes
color.whiteness()1.28+ (deprecated)Legacy colors only; LibSass / Ruby Sass ✗
color.channel(…, "whiteness")1.79+Official recommended replacement
Related $whiteness on adjust/change/scale1.28+Writers for the same HWB channel

⚡ Quick Reference

GoalCode
Warm grey hexcolor.whiteness(#e1d7d2)82.3529411765%
Whitecolor.whiteness(white)100%
Blackcolor.whiteness(black)0%
Brand bluecolor.whiteness(#336699)20%
Modern readcolor.channel($c, "whiteness")
Change whitenesscolor.adjust($c, $whiteness: 10%)

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.

styles.scss
@use "sass:color";

@debug color.whiteness(#e1d7d2); // 82.3529411765%

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

How It Works

Sass converts the legacy hex into HWB coordinates and writes the whiteness channel as a percentage custom property.

Example 2 — White Is 100%, Black Is 0% (Official Docs)

The extremes of the whiteness scale.

styles.scss
@use "sass:color";

@debug color.whiteness(white); // 100%
@debug color.whiteness(black); // 0%

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

How It Works

White is entirely whiteness; black has no white mix. Handy for checking that your reader and migration path match the official scale.

📈 Practical Patterns

Brand tokens, HWB pairs, and simple pale/deep checks.

Example 3 — Brand Blue Whiteness

Measure how much white sits in a classic UI blue.

styles.scss
@use "sass:color";

$brand: #336699;

.brand {
  --whiteness: #{color.whiteness($brand)};
}

How It Works

#336699 lands at 20% whiteness—some white mix, but the hue still reads clearly as blue (paired with 40% blackness on the sibling page).

Example 4 — Pair Whiteness with Blackness

See both HWB mix channels for the official taupe sample.

styles.scss
@use "sass:color";

$tone: #e1d7d2;

.hwb-report {
  --whiteness: #{color.whiteness($tone)};
  --blackness: #{color.blackness($tone)};
  --sum: #{color.whiteness($tone) + color.blackness($tone)};
}

How It Works

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.

styles.scss
@use "sass:color";

$tone: #e1d7d2;

.report {
  --whiteness: #{color.whiteness($tone)};
  --look: #{if(color.whiteness($tone) >= 50%, "pale", "deep")};
}

How It Works

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.

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

⚠️ 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.

💡 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

Key Takeaways

Knowledge Unlocked

Five things to remember about color.whiteness()

Deprecated HWB whiteness reader—migrate to color.channel.

5
Core concepts
⚠️ 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).

Conclusion

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

Continue with color.blackness(), color.channel(), or adjust-hue().

Next: adjust-hue()

You learned deprecated color.whiteness()—next is the classic global hue helper.

adjust-hue() →

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