color.blue() belongs to the built-in sass:color module (Deprecated Functions). It returns a legacy color’s RGB blue channel as a unitless number from 0 to 255 at compile time. This page covers the RGB idea, siblings red / green, migration to color.channel(), and five compiled examples.
01
Concept
RGB blue 0–255
02
Status
Deprecated
03
Siblings
red() / green()
04
Legacy only
rgb / hsl / hwb
05
Migrate
color.channel()
06
Practice
5 examples
Concept
What Is color.blue()?
Blue here means the third channel in classic RGB—how much blue light the color mixes in. Official docs: color.blue() returns that channel as a number between 0 and 255. It only reads the value; it does not tint the color blue.
color.blue(#e1d7d2) → 210
color.blue(white) → 255
color.blue(black) → 0
💡
Beginner tip
Think of a hex like #336699 as three dials: red 51, green 102, blue 153. color.blue turns only the blue dial into a number you can store, compare, or log—handy in mixins and design-token audits.
Foundation
📝 Syntax
Load the color module, then pass a legacy color:
styles.scss
@use "sass:color";
// Deprecated — still works on legacy colors
color.blue($color)
// Optional — bring members into scope
@use "sass:color" as *;
blue($color)
// Recommended migration (Dart Sass 1.79+)
color.channel($color, "blue")
Parameters
Parameter
Type
Description
$color
Color
Must be in a legacy color space (rgb, hsl, or hwb).
Return value
Type
Meaning
Unitless number
RGB blue from 0 to 255.
Modules
📦 Loading sass:color & Migrating
Prefer the namespaced form. Bare blue() only works after @use "sass:color" as *;—otherwise CSS may keep the call as a plain string.
styles.scss
@use "sass:color";
// Old (deprecated, still available)
$b: color.blue(#e1d7d2); // 210
// New — preferred on Dart Sass 1.79+
$b: color.channel(#e1d7d2, "blue");
// Optional global-style import
@use "sass:color" as *;
$b: blue(#e1d7d2);
⚠️
Version note for color.channel
color.channel() needs Dart Sass 1.79+. On older compilers, keep color.blue() until you can upgrade—then migrate.
Details
🎨 RGB Trio: Red, Green, Blue
Official docs also list color.red() and color.green() the same way (deprecated readers for the other two channels). Together they rebuild the classic rgb(r, g, b) triple from any legacy color.
Blue high, red low → often a cooler / more cyan-leaning look
Blue 255 → full blue channel (white has all three at 255)
Blue 0 → no blue light (black is all zeros)
💡
Writing blue instead of reading
To change the blue channel, use color.adjust() or color.change() with $blue—not color.blue(), which only returns a number.
Compare
📋 color.blue vs color.channel
Helper
Job
Status
color.blue()
Read RGB blue on legacy colors
Deprecated / not recommended
color.channel($c, "blue")
Same read (and any other channel)
Preferred on Dart Sass 1.79+
color.adjust(..., $blue: …)
Change blue by a fixed amount
Writer, not a reader
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a finished number—no color.blue() call remains at runtime.
Feature
Dart Sass
Notes
color.blue() / blue()
Yes (deprecated)
Legacy colors only
Siblings red() / green()
Yes (deprecated)
Same pattern for the other RGB channels
color.channel(…, "blue")
1.79+
Official recommended replacement
LibSass / Ruby Sass
Globals likely
May lack modern @use / channel
Cheat Sheet
⚡ Quick Reference
Goal
Code
Warm hex
color.blue(#e1d7d2) → 210
White
color.blue(white) → 255
Black
color.blue(black) → 0
Brand blue
color.blue(#336699) → 153
Modern read
color.channel($c, "blue")
Change blue
color.adjust($c, $blue: 15)
Hands-On
Examples Gallery
Examples use color.blue(). Open View Compiled CSS for verified output (matches official Sass docs samples where noted).
📚 Getting Started
Official docs samples for everyday and extreme colors.
Blue is the strongest channel here (153), which matches the cool brand look. All three readers are deprecated—migrate to color.channel with "red" / "green" / "blue".
Because blue is a plain number, you can compare it to red in Sass. On Dart Sass 1.79+, swap both calls to color.channel and keep the same if() logic.
Example 5 — Global blue() with as *
Older stylesheets sometimes import the module into the current namespace.
styles.scss
@use "sass:color" as *;
.panel {
--blue: #{blue(#e1d7d2)};
}
📤 Compiled CSS:
.panel {
--blue: 210;
}
How It Works
With as *, blue() matches color.blue(). Prefer the namespaced form (then color.channel) when you modernize the file.
Applications
🚀 Real-World Use Cases
Reading legacy SCSS — recognize color.blue in older RGB workflows.
Safe migrations — replace with color.channel($c, "blue") on Dart Sass 1.79+.
Token audits — report full RGB triples for brand hexes.
Conditional mixins — treat high-blue colors as cool accents.
Teaching RGB — show that hex is three 0–255 dials.
🧠 How Compilation Works
1
Write SCSS
Call color.blue($c) or migrate to color.channel.
Source
2
Map to RGB
Sass views the legacy color in red / green / blue coordinates.
RGB
3
Read blue
You get a unitless value from 0 to 255.
Number
4
✓
CSS sees the number
Custom properties get finished values—not a Sass call.
Watch Out
⚠️ Common Pitfalls
Using it in new code — prefer color.channel($c, "blue").
Bare blue() without as * — may compile as a CSS function string.
Modern color spaces — $color must be legacy for color.blue.
Confusing with CSS blue — the named color is paint; this helper returns a number.
Expecting a color back — this helper reads a channel; use adjust/change to write.
Pro Tips
💡 Best Practices
✅ Do
Migrate to color.channel($c, "blue") on Dart Sass 1.79+
Use @use "sass:color" and namespaced color.blue()
Pair with red/green when auditing full RGB
Compare channel numbers in mixins for token rules
Document when a brand intentionally leans cool
❌ Don’t
Add new color.blue() calls in greenfield projects
Pass modern oklch colors into color.blue
Call bare blue() without importing the module
Expect the browser to re-run Sass at runtime
Use a reader when you meant to change blue
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.blue()
Deprecated RGB blue reader—migrate to color.channel.
5
Core concepts
📝01
Call
color.blue($c)
API
⚠️02
Status
Deprecated
Docs
🎨03
Returns
0 … 255
RGB
🔄04
Siblings
red() / green()
Trio
✓05
Replace
channel(..., "blue")
Migrate
❓ 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.
Did you know?
Official Sass docs keep dedicated RGB readers like color.blue() for compatibility, but the modern story is one API: color.channel($c, "blue")—the same pattern you use for red, green, hue, lightness, and more.
color.blue() reads a legacy color’s RGB blue channel as a number from 0 to 255. Treat it as deprecated documentation: prefer color.channel($color, "blue") for new SCSS on Dart Sass 1.79+.