color.invert() returns the inverse / negative of a color in a chosen space — like a photo negative, not just a hue spin. Load it with @use "sass:color". The global alias is invert().
Optional $weight (default 100%) blends between the original (0%) and the full negative (100%). Weight 50% always yields a medium-lightness gray in that space.
Pass $space when you can.
Official docs: for legacy colors $space is optional and defaults to the color’s own space. On Dart Sass 1.79+, pass it explicitly (e.g. $space: rgb).
Official samples.
color.invert(#b37399, $space: rgb) → #4c8c66. Partial: color.invert(#550e0c, 20%, $space: display-p3) soft-pulls toward the negative in Display P3.
Not CSS filter: invert().
Sass compiles a finished color. CSS filter: invert() is a runtime visual effect on an element or image.
Syntax
Syntax
SCSS
@use "sass:color";
color.invert(#b37399, $space: rgb); // #4c8c66
color.invert(#550e0c, 20%, $space: display-p3); // soft pull in Display P3
color.invert($brand, $weight: 50%); // medium gray
color.invert($brand, $weight: 30%); // partial negative
// Global alias
invert(#b37399);
Pattern: pick a brand color → full invert for a twin accent, or use $weight for a softer pull / mid gray.
Inverse / negative of a color — not a hue-only complement.
$weight blends original → negative; 50% = medium gray.
Pass $space on Dart Sass 1.79+; prefer color.invert().
Keep CSS filters for photos/UI chrome — not design tokens.
One line:color.invert builds a compile-time negative (with optional weight/space) — not a CSS filter.
Compile
Compile Notes
Conceptual flow:
flow.txt
1. @use "sass:color"
2. Resolve $color in $space (or legacy default space)
3. Build the full negative
4. Mix original ↔ negative using $weight
5. Emit a finished CSS color (hex / rgb / keyword)
Frequently Asked Questions
color.invert($color, $weight: 100%, $space: null) returns the inverse or negative of a color. Example: color.invert(#b37399, $space: rgb) is #4c8c66.
Weight must be between 0% and 100%. Higher values move closer to the full negative; lower values stay closer to the original. Weight 50% always produces a medium-lightness gray in that space.
Add @use "sass:color"; then call color.invert($brand) or color.invert($brand, $weight: 30%). Prefer the module form. The global alias is invert().
No. Sass color.invert() compiles to a finished color value. CSS filter: invert() is a runtime visual effect on an element or image.
Yes for a full invert (weight 100%) in the same space: color.invert(color.invert($c)) returns to the starting color for typical opaque colors.
The module form needs Dart Sass with @use (about 1.23+). The $space argument needs Dart Sass 1.79+. LibSass/Ruby Sass may expose a global invert() but lack the modern module API.