color.alpha() belongs to the built-in sass:color module (Deprecated Functions). It returns a color’s opacity as a number from 0 to 1 at compile time. This page covers the opacity() alias, the IE alpha(opacity=…) special case, the legacy-color rule, migration to color.channel(), and five compiled examples.
01
Concept
Read opacity 0–1
02
Status
Deprecated
03
Aliases
opacity() / alpha()
04
Legacy only
rgb / hsl / hwb
05
Migrate
color.channel()
06
Practice
5 examples
Concept
What Is color.alpha()?
Alpha means opacity. Official docs: color.alpha() returns the alpha channel of $color as a number between 0 (fully transparent) and 1 (fully opaque). It does not change the color—it only reads how see-through it is.
color.alpha(#e1d7d2) → 1 (opaque hex)
color.opacity(rgb(210, 225, 221, 0.4)) → 0.4
color.alpha(rgba(3, 51, 102, 0)) → 0
💡
Beginner tip
Think of a glass of colored water. 1 is solid paint; 0.4 is milky; 0 is invisible. Use color.alpha (or better, color.channel) when mixins or conditionals need that number—for example, “only add a shadow if this token is mostly opaque.”
Foundation
📝 Syntax
Load the color module, or use the global aliases:
styles.scss
@use "sass:color";
// Deprecated — still works on legacy colors
color.alpha($color)
opacity($color) // global alias
alpha($color) // global alias
// Recommended migration (Dart Sass 1.79+)
color.channel($color, "alpha")
Parameters
Parameter
Type
Description
$color
Color
Must be in a legacy color space (rgb, hsl, or hwb).
Return value
Type
Meaning
Number 0–1
Usual case: the color’s opacity (unitless).
Unquoted string
Special case: alpha(opacity=20) returns that IE filter string unchanged.
Modules
📦 Loading sass:color & Migrating
Official heads-up: because color.alpha() is redundant with color.channel(), prefer the channel reader in new SCSS.
styles.scss
@use "sass:color";
// Old (deprecated, still available)
$a: color.alpha(rgba(#036, 0.4)); // 0.4
// New — preferred on Dart Sass 1.79+
$a: color.channel(rgba(#036, 0.4), "alpha"); // 0.4
// Global aliases (legacy codebases)
$a: opacity(rgba(#036, 0.4));
$a: alpha(rgba(#036, 0.4));
⚠️
Version note for color.channel
color.channel() needs Dart Sass 1.79+. On older compilers (for example 1.69), keep color.alpha() / opacity() until you can upgrade—then migrate.
Details
🎨 The IE alpha(opacity=…) Special Case
Official docs call out a historical quirk: global alpha(opacity=20) does not read a color. Sass supports the old Internet Explorer filter syntax and returns an unquoted stringalpha(opacity=20).
Useful only when emitting legacy IE filter / -ms-filter CSS.
Do not confuse it with color.alpha($color), which returns 0–1.
New projects should avoid IE filter strings entirely.
💡
Related helper
For full #AARRGGBB IE filter colors, see color.ie-hex-str()—also a legacy / deprecated use case.
Compare
📋 color.alpha vs color.channel
Same number for opacity—different futures.
Helper
Job
Status
color.alpha() / opacity()
Read alpha on legacy colors
Deprecated / not recommended
color.channel($c, "alpha")
Read alpha (and any other channel)
Preferred modern API (1.79+)
color.adjust(..., $alpha: …)
Change opacity relatively
Writer, not a reader
Support
🛠 Compatibility
This is about Sass compilers, not browsers. Compiled CSS receives a finished number or string—no color.alpha() call remains at runtime.
Feature
Dart Sass
Notes
color.alpha() / opacity()
Yes (deprecated)
Legacy colors only
alpha(opacity=…) IE form
Yes
Returns unquoted string
color.channel(…, "alpha")
1.79+
Official recommended replacement
LibSass / Ruby Sass
Globals likely
May lack modern @use / channel
Cheat Sheet
⚡ Quick Reference
Goal
Code
Opaque hex
color.alpha(#e1d7d2) → 1
Partial opacity
color.opacity(rgb(210, 225, 221, 0.4)) → 0.4
Fully transparent
color.alpha(rgba(3, 51, 102, 0)) → 0
IE filter string
alpha(opacity=20) → alpha(opacity=20)
Modern read
color.channel($c, "alpha")
Change opacity
color.adjust($c, $alpha: -0.2) or color.scale
Hands-On
Examples Gallery
Examples use color.alpha() / opacity() where noted. Open View Compiled CSS for verified output (matches official Sass docs samples).
📚 Getting Started
Official docs samples for opaque and translucent colors.
Sass recognizes the Internet Explorer syntax and returns an unquoted string so the compiled CSS keeps alpha(opacity=20). Skip this in modern stylesheets.
Any legacy color with an alpha channel reports a unitless number in the closed interval 0…1. Global opacity() matches color.alpha() for color arguments.
Example 5 — Branch on Opacity in a Mixin-Friendly Report
Use the alpha number in simple if() checks when building tokens.
Because alpha is a plain number, you can compare it in Sass. On Dart Sass 1.79+, swap color.alpha($brand) for color.channel($brand, "alpha") and keep the same logic.
Safe migrations — replace with color.channel($c, "alpha") on Dart Sass 1.79+.
Token audits — flag colors that are fully transparent or nearly opaque.
Conditional mixins — skip shadows or borders when alpha is too low.
IE maintenance only — understand alpha(opacity=…) when editing old filter CSS.
🧠 How Compilation Works
1
Write SCSS
Call color.alpha($c) or migrate to color.channel.
Source
2
Read alpha
Sass inspects the color’s opacity channel (legacy spaces).
Inspect
3
Emit a number
You get a unitless value from 0 to 1 (or an IE string).
Number
4
✓
CSS sees the value
Custom properties and calc get finished numbers—not a Sass call.
Watch Out
⚠️ Common Pitfalls
Using it in new code — prefer color.channel($c, "alpha").
Confusing IE syntax — alpha(opacity=20) is a string, not 0.2.
Modern color spaces — $color must be legacy for color.alpha.
Expecting a color back — this helper reads a number; use adjust / change to write opacity.
Assuming channel on old Sass — needs 1.79+; keep alpha until you upgrade.
Pro Tips
💡 Best Practices
✅ Do
Migrate to color.channel($c, "alpha") on Dart Sass 1.79+
Use @use "sass:color" and namespaced calls when possible
Compare alpha numbers in mixins for token rules
Document when a token is intentionally translucent
Treat IE alpha(opacity=…) as legacy-only
❌ Don’t
Add new color.alpha() calls in greenfield projects
Pass modern oklch colors into color.alpha
Assume alpha(opacity=20) means 0.2
Expect the browser to re-run Sass at runtime
Use a reader when you meant to change opacity
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about color.alpha()
Deprecated opacity reader—migrate to color.channel.
5
Core concepts
📝01
Call
color.alpha($c)
API
⚠️02
Status
Deprecated
Docs
🎨03
Returns
0 … 1 number
Read
📦04
Alias
opacity() too
Global
✓05
Replace
channel(..., "alpha")
Migrate
❓ Frequently Asked Questions
color.alpha($color) returns the alpha channel as a number between 0 and 1. Example: color.alpha(#e1d7d2) is 1; color.opacity(rgb(210, 225, 221, 0.4)) is 0.4.
Yes. Official Sass docs list it under Deprecated Functions and say it is no longer recommended because it is redundant with color.channel($color, "alpha").
For a color argument they are aliases: both return 0–1. opacity($color) is the same idea as color.alpha($color). Prefer the modern color.channel form in new code.
That is a special Internet Explorer filter syntax. Sass returns the unquoted string alpha(opacity=20) instead of reading a color’s alpha.
Official docs require a legacy color space (rgb, hsl, or hwb). Convert first with color.to-space(), or read alpha with color.channel on Dart Sass 1.79+.
Replace color.alpha($color) with color.channel($color, "alpha") after @use "sass:color" on Dart Sass 1.79+. Keep color.alpha only when maintaining older compilers or legacy SCSS.
Did you know?
Official Sass docs keep color.alpha() around for compatibility, but the modern story is one general reader: color.channel() can fetch alpha, red, hue, lightness, and more with the same API—so a dedicated alpha helper became redundant.
color.alpha() (and opacity()) read a legacy color’s opacity as a number from 0 to 1. Treat them as deprecated documentation: prefer color.channel($color, "alpha") for new SCSS on Dart Sass 1.79+.