rgb() is a global Sass color constructor. It builds an RGB color from red, green, and blue channels—with or without alpha—or sets a new alpha on an existing color with rgb($color, $alpha).
Official Sass docs list it under Global Functions (CSS-compatible). It is not deprecated. Alias: rgba() (same signatures in modern Dart Sass).
Global constructor — builds RGB colors at compile time.
Not deprecated — listed under Global Functions.
Alias:rgba() in modern Dart Sass.
Use commas when channels are variables; slash is for literals.
One line: use rgb() to build (or re-alpha) RGB tokens — prefer commas with variables, and color.change when you already live in sass:color.
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Build opaque colors with rgb($r, $g, $b) or Level 4 spaces
2. Add alpha with commas or rgb(... / $alpha) for literals
3. Prefer rgb($r, $g, $b, $a) whenever variables are involved
4. Use rgb($color, $alpha) to keep channels and set opacity
5. Or color.change($color, $alpha: ...) inside @use "sass:color"
Frequently Asked Questions
rgb() builds an RGB color from red, green, and blue channels, optionally with alpha. Example: rgb(0 51 102) is #036; rgb(#f2ece4, 50%) is rgba(242, 236, 228, 0.5).
In modern Dart Sass, yes—they are aliases and accept the same signatures. Historically rgba required alpha and rgb forbade it; LibSass still follows those stricter name rules.
No. Official Sass docs list rgb()/rgba() under Global Functions as CSS-compatible color constructors. They are not in the Deprecated Functions list.
When you already use @use "sass:color" and only need to set alpha (or other channels) on a token. color.change(#6b717f, $alpha: 0.5) matches rgb(#6b717f, 0.5).
Sass slash-parsing rules make rgb($r $g $b / $alpha) awkward when $b or $alpha is a variable. Official docs recommend rgb($r, $g, $b, $alpha) instead.
If you pass special CSS functions like var() for a channel, Sass returns an unquoted string with the same signature so the browser can resolve it at runtime.