color.is-legacy() returns a boolean: true when $color is in a legacy color space (rgb, hsl, or hwb), otherwise false. Load it with @use "sass:color" on Dart Sass 1.79+. There is no separate global alias.
Hex codes and CSS named colors count as legacy rgb. Modern writings such as oklch(), lab(), and color(srgb …) are not legacy.
Historical Sass color behaviors (flexible adjust / change, default $space rules) treat legacy colors specially. Use this helper when auditing tokens or branching shared mixins during an oklch migration.
Examples target Dart Sass 1.79+. Booleans are interpolated into custom properties so you can open View Compiled CSS. @debug lines print to the compiler terminal / log.
Example 1 — Official True / False Trio
Hex and HSL are legacy; oklch is not (official docs samples).
Modern spaces return false — oklch, lab, color(srgb …), …
Dart Sass 1.79+ module API only — no global alias.
Use for audits & mixin guards while migrating palettes.
One line:color.is-legacy answers whether a color still lives in the old rgb/hsl/hwb trio.
Compile
Compile Notes
Conceptual flow:
flow.txt
1. @use "sass:color" (Dart Sass 1.79+)
2. Inspect $color’s space
3. Return true for rgb / hsl / hwb (incl. hex & names)
4. Return false for modern spaces
5. CSS sees only the boolean or the branched result
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".