color.hue() belongs to the built-in sass:color module (Deprecated Functions). It returns a legacy color’s HSL hue as a number from 0deg to 360deg at compile time. This page covers the color-wheel idea, siblings saturation / lightness, migration to color.channel(), and five compiled examples.
01
Concept
HSL hue 0deg–360deg
02
Status
Deprecated
03
Siblings
saturation() / lightness()
04
Legacy only
rgb / hsl / hwb
05
Migrate
color.channel()
06
Practice
5 examples
Concept
What Is color.hue()?
Hue is the angle on the HSL color wheel—where the color sits between red, yellow, green, cyan, blue, and magenta. Official docs: color.hue() returns that angle as a number between 0deg and 360deg. It only reads the value; it does not rotate the color.
color.hue(#e1d7d2) → 20deg
color.hue(#f2ece4) → 34.2857142857deg
color.hue(#dadbdf) → 228deg
💡
Beginner tip
Think of HSL as three dials: hue (angle), saturation (how vivid), and lightness (how bright). color.hue turns only the angle 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.hue($color)
// Optional — bring members into scope
@use "sass:color" as *;
hue($color)
// Recommended migration (Dart Sass 1.79+)
color.channel($color, "hue")
Parameters
Parameter
Type
Description
$color
Color
Must be in a legacy color space (rgb, hsl, or hwb).
Return value
Type
Meaning
Number (with deg)
HSL hue from 0deg to 360deg.
Modules
📦 Loading sass:color & Migrating
Prefer the namespaced form. Bare hue() 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)
$h: color.hue(#e1d7d2); // 20deg
// New — preferred on Dart Sass 1.79+
$h: color.channel(#e1d7d2, "hue");
// Optional global-style import
@use "sass:color" as *;
$h: hue(#e1d7d2);
⚠️
Version note for color.channel
color.channel() needs Dart Sass 1.79+. On older compilers, keep color.hue() until you can upgrade—then migrate.
Details
🎨 HSL Trio: Hue, Saturation, Lightness
Official docs also list color.saturation() and color.lightness() the same way (deprecated readers for the other two HSL channels). Together they rebuild the classic hsl(h, s, l) triple from any legacy color.
Hue near 0deg / 360deg → reds on the classic wheel
hsl(200deg, …) reads back as 200deg. Brand hex #336699 lands nearby at 210deg—both sit in the cool cyan–blue band.
Example 5 — Global hue() with as *
Older stylesheets sometimes import the module into the current namespace.
styles.scss
@use "sass:color" as *;
.panel {
--hue: #{hue(#e1d7d2)};
}
📤 Compiled CSS:
.panel {
--hue: 20deg;
}
How It Works
With as *, hue() matches color.hue(). Prefer the namespaced form (then color.channel) when you modernize the file.
Applications
🚀 Real-World Use Cases
Reading legacy SCSS — recognize color.hue in older HSL workflows.
Safe migrations — replace with color.channel($c, "hue") on Dart Sass 1.79+.
Token audits — sort brand hexes by warmth on the color wheel.
Conditional mixins — treat hues near 0deg as warm and near 240deg as cool.
Teaching HSL — show that every color has an angle, even soft grays.
🧠 How Compilation Works
1
Write SCSS
Call color.hue($c) or migrate to color.channel.
Source
2
Map to HSL
Sass views the legacy color in hue / saturation / lightness.
HSL
3
Read hue
You get a number from 0deg to 360deg.
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, "hue").
Bare hue() without as * — may compile as a CSS function string.
Modern color spaces — $color must be legacy for color.hue.
Confusing with CSS hue() / relative color — Sass runs at compile time; CSS relative color is a different feature.
Expecting a color back — this helper reads an angle; use adjust/change to rotate.
Pro Tips
💡 Best Practices
✅ Do
Migrate to color.channel($c, "hue") on Dart Sass 1.79+
Use @use "sass:color" and namespaced color.hue()
Pair with saturation/lightness when auditing full HSL
Compare hue angles in mixins for warm/cool token rules
Document intentional brand hues on the wheel
❌ Don’t
Add new color.hue() calls in greenfield projects
Pass modern oklch colors into color.hue
Call bare hue() without importing the module
Expect the browser to re-run Sass at runtime
Use a reader when you meant to rotate hue
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.hue()
Deprecated HSL hue reader—migrate to color.channel.
5
Core concepts
📝01
Call
color.hue($c)
API
⚠️02
Status
Deprecated
Docs
🎨03
Returns
0deg … 360deg
HSL
🔄04
Siblings
saturation() / lightness()
Trio
✓05
Replace
channel(..., "hue")
Migrate
❓ Frequently Asked Questions
color.hue($color) returns the HSL hue of a legacy color as a number between 0deg and 360deg. Example: color.hue(#e1d7d2) is 20deg; color.hue(#f2ece4) is about 34.29deg; color.hue(#dadbdf) is 228deg.
Yes. Official Sass docs list it under Deprecated Functions and say it is no longer recommended because it is redundant with color.channel($color, "hue").
A number from 0deg to 360deg (with the deg unit). It is still a Sass number—meta.type-of reports number.
Official docs require a legacy color space (rgb, hsl, or hwb). Convert first, or use color.channel($color, "hue", $space: hsl) on Dart Sass 1.79+.
color.hue(), color.saturation(), and color.lightness() are sibling deprecated readers for the three HSL channels. Prefer color.channel with "hue", "saturation", or "lightness" in new code.
Replace color.hue($color) with color.channel($color, "hue") after @use "sass:color" on Dart Sass 1.79+. Keep color.hue only when maintaining older compilers or legacy SCSS.
Did you know?
Official Sass docs keep dedicated HSL readers like color.hue() for compatibility, but the modern story is one API: color.channel($c, "hue")—the same pattern you use for saturation, lightness, red, green, and more.
color.hue() reads a legacy color’s HSL hue as a number from 0deg to 360deg. Treat it as deprecated documentation: prefer color.channel($color, "hue") for new SCSS on Dart Sass 1.79+.