Sass color.blue()

Beginner
10 min read
Updated: Nov 2026
5 examples
Deprecated reader

Definition and Usage

color.blue($color) returns the RGB blue channel of a legacy color as a unitless number between 0 and 255. Global alias: blue($color).

Official Sass docs mark it deprecated — prefer color.channel($color, "blue") on Dart Sass 1.79+. Pair with color.red() and color.green() when auditing a full RGB triple.

No longer recommended.

Because color.blue() is redundant with color.channel(), migrate readers to the channel API in new code.

Official samples.

color.blue(#e1d7d2) → 210. white → 255. black → 0.

Legacy colors only.

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

Syntax

SCSS
@use "sass:color";

// Deprecated reader
color.blue(#e1d7d2); // 210
color.blue(white);   // 255
color.blue(black);   // 0

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

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

Migrate to color.channel

Side-by-side mapping:

Legacy / currentPrefer (1.79+)
color.blue($c)color.channel($c, "blue")
blue($c) (global)color.channel($c, "blue")
color.red($c) / color.green($c)color.channel($c, "red") / "green"
Force RGB spacecolor.channel($c, "blue", $space: rgb)

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

SCSS Examples

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

Example 1 — Warm Hex Blue Channel (Official Docs)

A soft taupe hex reports blue 210.

SCSS
@use "sass:color";

@debug color.blue(#e1d7d2); // 210

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

How It Works

  1. Legacy hex is read in RGB.
  2. Blue channel is the unitless number 210.
  3. Interpolation writes it into a custom property.
  4. Same read via color.channel(#e1d7d2, "blue") on 1.79+.

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

The extremes of the 8-bit blue scale.

SCSS
@use "sass:color";

@debug color.blue(white); // 255
@debug color.blue(black); // 0

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

How It Works

  1. White maxes every RGB channel → blue 255.
  2. Black zeros every channel → blue 0.
  3. Handy check that your reader matches the official scale.
  4. Migration path should produce the same extremes.

Example 3 — Full RGB Report for a Brand Hex

Read red, green, and blue together for #336699.

SCSS
@use "sass:color";

$brand: #336699;

.rgb-report {
  --red: #{color.red($brand)};
  --green: #{color.green($brand)};
  --blue: #{color.blue($brand)};
}

How It Works

  1. Blue is strongest here (153).
  2. Matches the cool brand look of #336699.
  3. All three readers are deprecated siblings.
  4. Migrate to color.channel with "red" / "green" / "blue".

Example 4 — Detect a Cool Bias with Blue vs Red

Compare channels on shorthand #036 (#003366).

SCSS
@use "sass:color";

.deep {
  --blue: #{color.blue(#036)};
  --bias: #{if(color.blue(#036) > color.red(#036), "cool", "warm")};
}

How It Works

  1. Blue is a plain number, so comparisons work in Sass.
  2. #036 expands to #003366.
  3. Blue 102 > red 0 → label cool.
  4. On 1.79+, swap both calls to color.channel and keep the if().

Example 5 — Global blue() with as *

Older stylesheets sometimes import the module into the current namespace.

SCSS
@use "sass:color" as *;

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

How It Works

  1. as * brings members into the current scope.
  2. blue() matches color.blue().
  3. Result is still official 210.
  4. Prefer namespaced color.blue, then color.channel, when modernizing.

Edge Cases & Pitfalls

Most blue-reader bugs are writing vs reading, modern spaces, or confusing CSS named color.

read

Readers do not change blue

color.blue only returns a number. To shift blue, use color.adjust / color.change with $blue.

space

Legacy colors only for this helper

Official docs require rgb / hsl / hwb. Prefer color.channel(..., $space: rgb) for modern spaces.

name

Not the CSS keyword blue

color.blue($c) reads a channel. The named color blue is a different value entirely.

migrate

Quote the channel name

Write color.channel($c, "blue") with a quoted string.

Sass Support

color.blue() remains for compatibility. New readers should use color.channel on Dart Sass 1.79+.

APIStatus
color.blue() / blue()Deprecated reader — still works on legacy colors
color.channel($c, "blue")Preferred on Dart Sass 1.79+
LibSass / Ruby SassGlobal blue() may exist — no modern module path
BrowsersN/A — only see compiled CSS values

Compile with the Dart Sass CLI.

Key Takeaways

  • Reads RGB blue as a unitless number from 0 to 255.
  • Deprecated in favor of color.channel($c, "blue").
  • Siblings: color.red() and color.green().
  • Writers use adjust/change with $blue — not this reader.

One line: use color.blue to understand old RGB reads — write new ones with color.channel.

Migrate Notes

Practical checklist:

migrate.txt
1. Find color.blue($c) / blue($c) in legacy SCSS
2. Require Dart Sass 1.79+ for color.channel
3. Replace with color.channel($c, "blue")
4. Add $space: rgb when reading non-legacy colors
5. Use adjust/change when you need to write blue

Frequently Asked Questions

color.blue($color) returns the RGB blue channel as a number between 0 and 255. Example: color.blue(#e1d7d2) is 210; color.blue(white) is 255; color.blue(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, "blue").
A unitless number from 0 to 255, matching classic 8-bit RGB blue.
Official docs require a legacy color space (rgb, hsl, or hwb). Convert first, or use color.channel($color, "blue", $space: rgb) on Dart Sass 1.79+.
color.red(), color.green(), and color.blue() are sibling deprecated readers for the three RGB channels. Prefer color.channel with "red", "green", or "blue" in new code.
Replace color.blue($color) with color.channel($color, "blue") after @use "sass:color" on Dart Sass 1.79+. Keep color.blue only when maintaining older compilers or legacy SCSS.

Next: Sass darken()

Deprecated helper that subtracts HSL lightness — prefer color.adjust / scale.

darken() →

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