Home Sass Color color.blue() Sass color.blue() Definition
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
Syntax @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").
Code
SCSS Examples Examples use color.blue(). Open View Compiled CSS for verified output (matches official Sass docs samples where noted).
1. Hex 2. White / black 3. RGB report 4. Cool bias 5. Global alias Example 1 — Warm Hex Blue Channel (Official Docs) A soft taupe hex reports blue 210.
@use "sass:color";
@debug color.blue(#e1d7d2); // 210
.swatch {
--blue: #{color.blue(#e1d7d2)};
} How It Works Legacy hex is read in RGB.Blue channel is the unitless number 210.Interpolation writes it into a custom property.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.
@use "sass:color";
@debug color.blue(white); // 255
@debug color.blue(black); // 0
.extremes {
--white: #{color.blue(white)};
--black: #{color.blue(black)};
} .extremes {
--white: 255;
--black: 0;
} How It Works White maxes every RGB channel → blue 255.Black zeros every channel → blue 0.Handy check that your reader matches the official scale.Migration path should produce the same extremes.Example 3 — Full RGB Report for a Brand Hex Read red, green, and blue together for #336699.
@use "sass:color";
$brand: #336699;
.rgb-report {
--red: #{color.red($brand)};
--green: #{color.green($brand)};
--blue: #{color.blue($brand)};
} .rgb-report {
--red: 51;
--green: 102;
--blue: 153;
} How It Works Blue is strongest here (153).Matches the cool brand look of #336699.All three readers are deprecated siblings.Migrate to color.channel with "red" / "green" / "blue".Example 4 — Detect a Cool Bias with Blue vs Red Compare channels on shorthand #036 (#003366).
@use "sass:color";
.deep {
--blue: #{color.blue(#036)};
--bias: #{if(color.blue(#036) > color.red(#036), "cool", "warm")};
} .deep {
--blue: 102;
--bias: cool;
} How It Works Blue is a plain number , so comparisons work in Sass.#036 expands to #003366.Blue 102 > red 0 → label cool.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.
@use "sass:color" as *;
.panel {
--blue: #{blue(#e1d7d2)};
} How It Works as * brings members into the current scope.blue() matches color.blue().Result is still official 210.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.
Toolchain
Sass Support color.blue() remains for compatibility. New readers should use color.channel on Dart Sass 1.79+.
API Status color.blue() / blue()Deprecated reader — still works on legacy colors color.channel($c, "blue")Preferred on Dart Sass 1.79+ LibSass / Ruby Sass Global blue() may exist — no modern module path Browsers N/A — only see compiled CSS values
Compile with the Dart Sass CLI .
Remember
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
Migrate Notes Practical checklist:
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 What does Sass color.blue() do? 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.
Is color.blue() deprecated? 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").
What range does color.blue() return? A unitless number from 0 to 255, matching classic 8-bit RGB blue.
Does color.blue() work on oklch colors? 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+.
How do red, green, and blue readers relate? 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.
How do I migrate old color.blue() calls? 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 Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion