color.is-legacy() belongs to the built-in sass:color module. It answers one boolean question: is this color in a legacy color space? This page covers which spaces count as legacy, why that matters for other color helpers, the Dart Sass 1.79+ requirement, and five examples.
01
Concept
Legacy vs modern
02
Module
@use "sass:color"
03
Legacy
rgb · hsl · hwb
04
Modern
oklch · lab · srgb
05
Needs
Dart Sass 1.79+
06
Practice
5 examples
Concept
What Is color.is-legacy()?
is-legacy means “tell me if this color still lives in the old CSS/Sass trio.” Official docs: it returns whether $color is in a legacy color space. That boolean helps when you mix classic hex tokens with modern oklch designs.
color.is-legacy(#b37399) → true
color.is-legacy(hsl(90deg 30% 90%)) → true
color.is-legacy(oklch(70% 10% 120deg)) → false
💡
Beginner tip
Hex, rgb(), named colors like rebeccapurple, hsl(), and hwb() are legacy. Spaces such as oklch, lab, and color(srgb …) are not.
true if the color is in rgb, hsl, or hwb; otherwise false.
Modules
📦 Loading sass:color
There is no separate global is-legacy() built-in. Use the module form on Dart Sass 1.79+.
styles.scss
// Recommended — namespaced (Dart Sass 1.79+)
@use "sass:color";
$ok: color.is-legacy(#b37399);
// Optional — bring members into the current namespace
@use "sass:color" as *;
$ok: is-legacy(#b37399);
// Optional — custom namespace
@use "sass:color" as c;
$ok: c.is-legacy(#b37399);
⚠️
Version gate
If Dart Sass reports Undefined function for color.is-legacy, upgrade to 1.79+. Older compilers do not include this helper.
Spaces
🎨 Which Spaces Are Legacy?
Official Sass color documentation treats these three as the legacy spaces. Hex and CSS color names count as rgb.
Space
is-legacy?
Common writings
rgb
true
#b37399, rgb(...), rebeccapurple
hsl
true
hsl(90deg 30% 90%)
hwb
true
hwb(270 20% 40%)
oklch / lab / …
false
oklch(70% 10% 120deg)
srgb (modern)
false
color(srgb 0.4 0.2 0.6) — not the same as legacy rgb
Why
💡 Why Legacy Matters
Legacy colors keep special historical behavior in helpers like color.adjust(), color.change(), and color.complement()—for example flexible channel mixing across rgb/hsl/hwb and optional $space defaults. Modern colors usually require explicit spaces and stricter channel rules.
Situation
How is-legacy helps
Migrating a palette to oklch
Flag which tokens still need legacy-friendly helpers
Writing shared mixins
Branch: pass $space for modern colors, keep defaults for hex
Debugging channel errors
Confirm whether Sass is treating the color as legacy
Support
🛠 Compatibility
This is about Sass compilers, not browsers. The boolean is resolved at compile time—CSS never sees a color.is-legacy() call.
Feature
Dart Sass
Notes
color.is-legacy()
1.79+
Part of the modern color-spaces work
Related color.is-in-gamut()
1.79+
Sibling boolean about channel bounds
LibSass / Ruby Sass
✗
No modern module color-space API
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import color
@use "sass:color";
Test a hex
color.is-legacy(#b37399) → true
Test HSL
color.is-legacy(hsl(90deg 30% 90%)) → true
Test oklch
color.is-legacy(oklch(70% 10% 120deg)) → false
Branch in SCSS
if(color.is-legacy($c), …, …)
Hands-On
Examples Gallery
Examples target Dart Sass 1.79+. Open View Compiled CSS to see the booleans Sass emits into custom properties or content.
if() runs at compile time. Hex takes the legacy branch; oklch takes the modern branch. Real mixins might choose different adjust/change call shapes instead of labels.
Official docs note that srgb is equivalent in spirit to rgb, but only rgb is legacy. Writing color(srgb …) opts into the modern space model.
Applications
🚀 Real-World Use Cases
Design-system migration — inventory which tokens are still legacy hex/HSL.
Shared mixins — choose legacy-friendly defaults vs explicit $space.
CI / debug dumps — emit boolean flags while auditing a palette file.
Docs & teaching — show rgb/hsl/hwb vs oklch with a one-line test.
Safe refactors — refuse certain channel ops unless the color is legacy (or vice versa).
🧠 How Compilation Works
1
Write SCSS
Call color.is-legacy($color) after @use.
Source
2
Read the color space
Sass checks whether the color is rgb, hsl, or hwb.
Inspect
3
Return a boolean
true for legacy spaces, false otherwise.
Boolean
4
✓
Plain CSS ships
Browsers see true/false text or branched results—not a Sass call.
Watch Out
⚠️ Common Pitfalls
Old Dart Sass — color.is-legacy needs 1.79+.
Confusing rgb with srgb — modern color(srgb …) is not legacy.
Expecting a color back — this helper returns a boolean, not a converted color.
Assuming “legacy” means deprecated CSS — hex/HSL are still normal; “legacy” is Sass’s space category.
Looking for a global alias — use color.is-legacy() from the module.
Pro Tips
💡 Best Practices
✅ Do
Run Dart Sass 1.79+ before relying on is-legacy
Use it in mixins that support both hex and oklch tokens
Pair with explicit $space when working on modern colors
Document which brand tokens are still legacy
Prefer @use "sass:color"
❌ Don’t
Ship CI on older Dart Sass and expect this function to exist
Treat false as “invalid color”
Assume color(srgb …) behaves like legacy rgb
Rely on LibSass / Ruby Sass
Skip $space on modern colors just because hex defaults worked
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.is-legacy()
Boolean space check—rgb/hsl/hwb vs modern color spaces, Dart Sass 1.79+.
5
Core concepts
📝01
Call
is-legacy($color)
API
📦02
Needs
Dart Sass 1.79+
Version
🎨03
True for
rgb / hsl / hwb
Legacy
⚡04
False for
oklch / srgb
Modern
✓05
Returns
boolean
Check
❓ Frequently Asked Questions
color.is-legacy($color) returns true if the color is in a legacy color space (rgb, hsl, or hwb), and false otherwise. Example: color.is-legacy(#b37399) is true; color.is-legacy(oklch(70% 10% 120deg)) is false.
Official Sass color docs treat rgb, hsl, and hwb as legacy. Hex colors and CSS color names are part of the rgb legacy space.
No. The modern srgb space is not the same as legacy rgb, even though they describe similar colors. is-legacy() returns false for color(srgb ...).
Many historical Sass color behaviors (flexible channel mixing on adjust/change, default $space rules) apply specially to legacy colors. Knowing which tokens are legacy helps when migrating to oklch and friends.
No. Use the module form color.is-legacy() after @use "sass:color".
Did you know?
Official Sass docs introduce color.is-legacy() alongside color.is-in-gamut() as part of the modern color-spaces work. Legacy is not an insult to hex—it is Sass’s name for the historical rgb / hsl / hwb trio that still gets special compatibility behavior.
color.is-legacy() is the boolean check for whether a color still lives in rgb, hsl, or hwb. Use it while migrating palettes and writing mixins that support both hex and modern spaces—on Dart Sass 1.79+.