Sass color.whiteness()

Beginner
12 min read
Updated: Nov 2026
5 examples
Dart Sass 1.28+

Definition and Usage

color.whiteness($color) returns the HWB whiteness of a legacy color as a number between 0% and 100%. Global alias: whiteness($color). Available since Dart Sass 1.28+.

Official Sass docs mark it deprecated — prefer color.channel($color, "whiteness", $space: hwb) on Dart Sass 1.79+. Pair with color.blackness() when auditing a full HWB mix.

No longer recommended.

Because color.whiteness() is redundant with color.channel(), migrate readers to the channel API in new code. Pass $space: hwb for hex/rgb colors — rgb has no whiteness channel of its own.

Official samples.

color.whiteness(#e1d7d2) → 82.3529411765%. white → 100%. black → 0%.

Legacy colors only.

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

Syntax

SCSS
@use "sass:color";

// Deprecated reader (Dart Sass 1.28+)
color.whiteness(#e1d7d2); // 82.3529411765%
color.whiteness(white);   // 100%
color.whiteness(black);   // 0%

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

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

Migrate to color.channel

Side-by-side mapping:

Legacy / currentPrefer (1.79+)
color.whiteness($c)color.channel($c, "whiteness", $space: hwb)
whiteness($c) (global)color.channel($c, "whiteness", $space: hwb)
color.blackness($c)color.channel($c, "blackness", $space: hwb)
Already in hwbcolor.channel($c, "whiteness") may omit $space

To change whiteness, use writers like color.scale($c, $whiteness: …, $space: hwb) or color.adjust($c, $whiteness: …, $space: hwb) — not the reader.

SCSS Examples

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

Example 1 — Warm Hex Whiteness (Official Docs)

A soft taupe hex reports HWB whiteness about 82.35%.

SCSS
@use "sass:color";

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

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

How It Works

  1. Legacy hex is mapped into HWB.
  2. Whiteness percent is about 82.35% (lots of white mixed in).
  3. Interpolation writes it into a custom property.
  4. Same read via color.channel(#e1d7d2, "whiteness", $space: hwb) on 1.79+.

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

The ends of the HWB whiteness scale.

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

  1. White is full whiteness 100%.
  2. Black is 0% whiteness (its blackness is 100%).
  3. Landmarks help decide if a tint is already chalky.
  4. On 1.79+, use color.channel with $space: hwb.

Example 3 — Whiteness + Blackness Pair

Same taupe: high whiteness, low blackness — and the channel migration.

SCSS
@use "sass:color";

.hwb-pair {
  --w: #{color.whiteness(#e1d7d2)};
  --b: #{color.blackness(#e1d7d2)};
  --channel: #{color.channel(#e1d7d2, "whiteness", $space: hwb)};
}

How It Works

  1. Whiteness ~82% and blackness ~12% describe the same taupe.
  2. channel with $space: hwb matches whiteness() exactly.
  3. Omit $space on a hex and Dart Sass errors — rgb has no whiteness.
  4. Migrate both whiteness and blackness the same way.

Example 4 — Soft, Mid, and Deep Whiteness

Read familiar seeds used across the color tutorials.

SCSS
@use "sass:color";

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

How It Works

  1. Soft taupe ~82% — already heavy on white mix.
  2. Deep navy at 0% — no white mixed in (pure-ish hue + blackness).
  3. Mid slate / brand sit between chalky and deep.
  4. Read first, then choose scale / adjust in hwb.

Example 5 — Global whiteness() with as *

Older stylesheets sometimes import the module into the current namespace.

SCSS
@use "sass:color" as *;

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

How It Works

  1. as * brings members into the current scope.
  2. whiteness() matches color.whiteness().
  3. Result is still the official ~82.35%.
  4. Prefer namespaced color.whiteness, then color.channel.

Edge Cases & Pitfalls

Most whiteness bugs are omitting $space: hwb on channel(), confusing HWB with HSL lightness, or using non-legacy colors.

space

Pass $space: hwb when migrating

color.channel(#hex, "whiteness") errors on rgb. Always add $space: hwb for hex/rgb tokens.

model

Whiteness ≠ lightness

HWB whiteness mixes white into a hue. HSL lightness is a different channel — see color.lightness().

legacy

Legacy colors only

oklch / display-p3 need color.channel(..., $space: hwb) or a convert-first path.

version

Needs Dart Sass 1.28+

color.whiteness() arrived in 1.28. Prefer channel once you are on 1.79+.

Sass Support

color.whiteness() is a deprecated module reader. Prefer color.channel on modern Dart Sass.

APIStatus
color.whiteness()Dart Sass 1.28+ (deprecated)
color.channel(..., "whiteness", $space: hwb)Preferred on Dart Sass 1.79+
Global whiteness()Available via module / legacy globals
LibSass / Ruby SassUnsupported

Compile with the Dart Sass CLI.

Key Takeaways

  • Reads HWB whiteness as 0%–100% on legacy colors.
  • Prefer color.channel with $space: hwb on Dart Sass 1.79+.
  • Pair with blackness when describing an HWB mix.
  • Not HSL lightness — different model, different channel.

One line: treat color.whiteness as legacy — new reads should use color.channel($c, "whiteness", $space: hwb).

Migrate Notes

Practical checklist:

checklist.txt
1. Find color.whiteness() / whiteness()
2. Replace with color.channel($c, "whiteness", $space: hwb)
3. Keep Dart Sass 1.28+ only if you cannot upgrade yet
4. Pair with blackness when auditing HWB mixes
5. Use scale / adjust (not the reader) to change whiteness

Frequently Asked Questions

color.whiteness($color) returns the HWB whiteness of a legacy color as a number between 0% and 100%. Example: color.whiteness(#e1d7d2) is about 82.35%; 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", $space: hwb).
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", $space: hwb) after @use "sass:color" on Dart Sass 1.79+. Hex/rgb colors need $space: hwb because rgb has no whiteness channel.

Next: Sass adjust-hue()

Deprecated global that shifts hue by a fixed amount.

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.

8 people found this page helpful