Sass
CSS preprocessor

Sass color.hue() Function

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
Deprecated
sass:color · Dart Sass

What You’ll Learn

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

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.

📝 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

ParameterTypeDescription
$colorColorMust be in a legacy color space (rgb, hsl, or hwb).

Return value

TypeMeaning
Number (with deg)HSL hue from 0deg to 360deg.

📦 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.

🎨 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
  • Hue near 120deg → greens (named lime is 120deg)
  • Hue near 240deg → blues (named blue is 240deg)
💡
Writing hue instead of reading

To rotate or set hue, use color.adjust(), color.change(), or the deprecated global adjust-hue()—not color.hue(), which only returns a number.

📋 color.hue vs color.channel

HelperJobStatus
color.hue()Read HSL hue on legacy colorsDeprecated / not recommended
color.channel($c, "hue")Same read (and any other channel)Preferred on Dart Sass 1.79+
color.adjust(..., $hue: …)Rotate hue by a fixed amountWriter, not a reader

🛠 Compatibility

This is about Sass compilers, not browsers. Compiled CSS receives a finished number—no color.hue() call remains at runtime.

FeatureDart SassNotes
color.hue() / hue()Yes (deprecated)Legacy colors only
Siblings saturation() / lightness()Yes (deprecated)Same pattern for the other HSL channels
color.channel(…, "hue")1.79+Official recommended replacement
LibSass / Ruby SassGlobals likelyMay lack modern @use / channel

⚡ Quick Reference

GoalCode
Warm taupecolor.hue(#e1d7d2)20deg
Creamcolor.hue(#f2ece4)34.2857142857deg
Cool graycolor.hue(#dadbdf)228deg
Brand hexcolor.hue(#336699)210deg
Modern readcolor.channel($c, "hue")
Rotate huecolor.adjust($c, $hue: 15deg)

Examples Gallery

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

📚 Getting Started

Official docs samples for warm, cream, and cool hues.

Example 1 — Warm Hex Hue (Official Docs)

A soft taupe hex reports hue 20deg.

styles.scss
@use "sass:color";

@debug color.hue(#e1d7d2); // 20deg

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

How It Works

Sass maps the legacy hex into HSL, reads the hue angle, and writes that number (with deg) into a custom property.

Example 2 — Cream and Cool Grays (Official Docs)

Two more official samples: a cream near orange-yellow, and a cool bluish gray.

styles.scss
@use "sass:color";

@debug color.hue(#f2ece4); // 34.2857142857deg
@debug color.hue(#dadbdf); // 228deg

.palette {
  --cream: #{color.hue(#f2ece4)};
  --cool: #{color.hue(#dadbdf)};
}

How It Works

Even soft neutrals carry a tiny hue. Cream sits near 34deg; the cool gray sits near blue at 228deg. Useful when you sort tokens by warmth.

📈 Practical Patterns

Named colors on the wheel, HSL input, and the global alias.

Example 3 — Primary Named Colors on the Wheel

Classic CSS names land on tidy wheel positions.

styles.scss
@use "sass:color";

.wheel {
  --red: #{color.hue(red)};
  --lime: #{color.hue(lime)};
  --blue: #{color.hue(blue)};
}

How It Works

These landmarks make mixins easier: compare a brand hue to 0deg, 120deg, or 240deg to decide warm vs cool accents.

Example 4 — Hue From an HSL Color

When the input is already HSL, the hue dial matches what you wrote.

styles.scss
@use "sass:color";

.card {
  --from-hsl: #{color.hue(hsl(200deg, 50%, 40%))};
  --brand: #{color.hue(#336699)};
}

How It Works

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)};
}

How It Works

With as *, hue() matches color.hue(). Prefer the namespaced form (then color.channel) when you modernize the file.

🚀 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.

⚠️ 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.

💡 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

Key Takeaways

Knowledge Unlocked

Five things to remember about color.hue()

Deprecated HSL hue reader—migrate to color.channel.

5
Core concepts
⚠️ 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.

Conclusion

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+.

Continue with lighten(), color.channel(), or color.adjust().

Next: lighten()

You learned deprecated color.hue()—next, raise HSL lightness with lighten().

lighten() →

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.

5 people found this page helpful