color.mix() belongs to the built-in sass:color module. It blends two colors at compile time. This page covers $weight, optional $method (Dart Sass 1.79+ / CSS color-mix() algorithm), the historical opacity-aware path, how it differs from CSS color-mix(), and five compiled examples.
01
Concept
Blend two colors
02
Module
@use "sass:color"
03
Weight
More of $color1
04
Method
Optional (1.79+)
05
Vs CSS
color-mix()
06
Practice
5 examples
Concept
What Is color.mix()?
Mix means “meet these two colors in the middle—or closer to one side.” Official docs return a color that is a mixture of $color1 and $color2. Design systems use it for hover tints, soft borders, and token ladders from a brand + a neutral.
A new color between $color1 and $color2, controlled by $weight (and $method when set).
Modules
📦 Loading sass:color
Prefer the module API. Official docs also document the global name mix() for older stylesheets.
styles.scss
// Recommended — namespaced
@use "sass:color";
$mid: color.mix(#036, #d2e1dd);
// Optional — bring members into the current namespace
@use "sass:color" as *;
$mid: mix(#036, #d2e1dd);
// Optional — custom namespace
@use "sass:color" as c;
$mid: c.mix(#036, #d2e1dd);
// Legacy global name
$mid: mix(#036, #d2e1dd);
⚠️
Put @use first
Keep @use "sass:color"; near the top of the file. Built-in modules need Dart Sass (about 1.23+). Passing $method needs 1.79+. Prefer color.mix() so it never looks like CSS color-mix().
Weight
⚖️ How $weight Works
Official docs: the weight must be between 0% and 100% (inclusive). A larger weight means more of $color1; a smaller weight means more of $color2.
Weight
Feels like
100%
Almost entirely $color1
50% (default)
Even blend of both
0%
Almost entirely $color2
Modern API
🎨 $method and CSS color-mix() Math
On Dart Sass 1.79+, pass $method as a color space name—and for polar spaces (hsl, hwb, lch, oklch) you may add a hue interpolation method such as longer hue. Official docs: this uses the same algorithm as CSS color-mix().
Missing channels in the interpolation space take the other color’s corresponding channel.
The result is always returned in $color1’s color space.
Example: color.mix(#036, #d2e1dd, $method: oklch) produces a different midtone than RGB mixing.
⚠️
Heads up from the docs
For historical reasons, $method is optional when both colors are in legacy spaces. Then Sass uses its older algorithm, where weight and relative opacity decide how much of each color appears in the result.
Compare
📋 Sass color.mix() vs CSS color-mix()
Both blend colors, but they run at different stages of the pipeline.
Sass color.mix()
CSS color-mix()
When it runs
Compile time (SCSS → CSS)
In the browser
What CSS receives
A finished color (hex/rgb/…)
The color-mix() function itself
Best for
Design tokens, fixed palette steps
Dynamic themes, runtime interpolation
Modern space control
$method (Dart Sass 1.79+)
First argument space (e.g. in oklch)
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a finished color—no color.mix() call remains (unless you intentionally write CSS color-mix() yourself).
Feature
Dart Sass
Notes
@use "sass:color" / color.mix
1.23+
Preferred module API
$weight + legacy mix
Long-standing
Opacity-aware when $method is omitted on legacy colors
$method (CSS algorithm)
1.79+
Matches CSS color-mix(); required for non-legacy spaces
Global mix()
Long-standing
Prefer module form in new SCSS
LibSass / Ruby Sass
No modern module API
May expose global mix(); prefer Dart Sass
Cheat Sheet
⚡ Quick Reference
Goal
Code
Import color
@use "sass:color";
Even blend
color.mix(#036, #d2e1dd)
More of first color
color.mix($a, $b, 75%)
More of second color
color.mix($a, $b, $weight: 25%)
RGB method (1.79+)
color.mix($a, $b, $method: rgb)
Oklch method (1.79+)
color.mix($a, $b, $method: oklch)
Hue path (1.79+)
color.mix($a, $b, $method: oklch longer hue)
CSS runtime mix (different)
color-mix(in srgb, #036 50%, #d2e1dd)
Legacy global
mix(#036, #d2e1dd)
Hands-On
Examples Gallery
Examples 1–3 and 5 compile on everyday Dart Sass. Example 4 shows official $method results for Dart Sass 1.79+. Open View Compiled CSS to inspect the output.
📚 Getting Started
Even blends, weight ladders, and opacity-aware historical mixes.
Example 1 — Even Blend of Two Brand Colors
Default 50% mix (classic docs pair: deep blue + mint).
Official docs note that the historical algorithm factors in each color’s opacity. The cream is only 50% opaque, so the result is a translucent gray—not a fully opaque midtone.
Example 4 — $method: RGB vs Oklch (Dart Sass 1.79+)
Same two hexes, different interpolation spaces (official docs samples).
RGB mixing lands on the familiar #698aa2. Oklch mixing follows perceptual space math (like CSS color-mix()). longer hue picks the long way around the hue circle when blending polar colors.
Example 5 — Sass Mix vs CSS color-mix() + Global Alias
Compile-time tokens next to a runtime CSS mix; module and global names match.
styles.scss
@use "sass:color";
.chip {
// Sass: finished color in the CSS file
color: color.mix(#036, #d2e1dd);
--module: #{color.mix(#036, #d2e1dd)};
--global: #{mix(#036, #d2e1dd)};
}
.chip.is-live {
// CSS: browser blends at paint time (not a Sass helper)
background: color-mix(in srgb, #036 50%, #d2e1dd);
}
Module and global Sass mixes compile to the same hex. The CSS color-mix() declaration is left for the browser—useful when a theme may change at runtime.
Applications
🚀 Real-World Use Cases
Hover / active tints — mix brand + surface for interactive states.
Border / divider softens — blend a strong accent toward white or gray.
Token ladders — generate 20% / 50% / 80% steps from two seed colors.
Overlay chips — historical opacity-aware mixes for translucent UI layers.
Perceptual midtones — use $method: oklch on Dart Sass 1.79+.
Teaching color math — compare Sass tokens with CSS color-mix().
🧠 How Compilation Works
1
Write SCSS
Call color.mix($c1, $c2, ...) after @use.
Source
2
Pick the algorithm
Use $method (1.79+) or the historical legacy mix.
Method
3
Apply weight
Bias toward $color1 or $color2 with $weight.
Blend
4
✓
Plain CSS color ships
Browsers receive hex/rgb/oklch—not a Sass call.
Watch Out
⚠️ Common Pitfalls
Reversing weight — bigger % means more of $color1, not more of $color2.
Confusing CSS color-mix() — runtime CSS syntax is not the Sass helper.
Using $method on older Dart Sass — needs 1.79+; bare color.mix($a, $b) still works earlier on legacy colors.
Ignoring opacity — historical mixes factor transparency into the result.
Expecting the same midtone in every space — rgb and oklch methods can disagree.
Pro Tips
💡 Best Practices
✅ Do
Use @use "sass:color" and color.mix() in new SCSS
Name tokens by intent ($hover, $border-soft)
Pass $method explicitly on Dart Sass 1.79+ when space matters
Keep CSS color-mix() for true runtime themes
Check contrast after mixing text and backgrounds
❌ Don’t
Expect the browser to re-run color.mix
Guess weight direction—test a ladder (20 / 50 / 80)
Assume RGB and oklch midtones match
Rely on LibSass for sass:color
Skip accessibility checks on mixed UI colors
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.mix()
Compile-time blends—tune with weight, choose a method on 1.79+.
5
Core concepts
📝01
Call
mix($c1, $c2)
API
📦02
Module
sass:color
@use
🎨03
Does
blend two colors
Mix
⚡04
Weight
more of $color1
Bias
✓05
Not CSS
color-mix()
Different
❓ Frequently Asked Questions
color.mix($color1, $color2, $weight: 50%, $method: null) returns a color that is a mixture of the two inputs. Example: color.mix(#036, #d2e1dd) is #698aa2.
Weight must be between 0% and 100%. A larger weight uses more of $color1; a smaller weight uses more of $color2. Default is 50% (an even blend).
On Dart Sass 1.79+, $method is a color space name (optionally with a hue interpolation method for hsl, hwb, lch, or oklch). Sass then mixes with the same algorithm as CSS color-mix(). Example: color.mix(#036, #d2e1dd, $method: oklch).
Same idea, different stage. Sass color.mix() runs at compile time and writes a finished color into CSS. CSS color-mix() runs in the browser. Prefer Sass when the blend must be fixed in the stylesheet.
Add @use "sass:color"; then call color.mix($a, $b) or color.mix($a, $b, 75%). Prefer the module form. The global alias is mix().
The module form needs Dart Sass with @use (about 1.23+). The $method argument needs Dart Sass 1.79+. LibSass/Ruby Sass may expose a global mix() but lack the modern module and $method API.
Did you know?
Official Sass docs show that with $method, a missing channel in one color borrows the matching channel from the other—just like CSS color-mix(). That is why mixing color(rec2020 0.8 none 0.3) with a full rec2020 color can fill in the missing channel instead of treating it as zero.
color.mix() is the clearest way to ask Sass for a two-color blend. Use $weight to bias the mix, pass $method on Dart Sass 1.79+ when you want CSS color-mix() math, and keep runtime color-mix() for live themes.