rgbToCss
Formats an RGB(A) color as a CSS rgb() value, in the modern space-separated syntax that
every current browser and SVG renderer reads.
Channels are clamped to 0-255 and rounded; alpha is clamped to 0-1, rounded to 3 decimals, and left out when the color is opaque.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | RgbColor | The color to format. `a` defaults to 1 (opaque) when omitted. |
Returns
Section titled “Returns”string — rgb(r g b), or rgb(r g b / a) when translucent
Examples
Section titled “Examples”Opaque color
Section titled “Opaque color”The alpha is left out.
Translucent color
Section titled “Translucent color”The alpha comes after a slash.
Related Types
Section titled “Related Types”RgbColor
Section titled “RgbColor”An RGB(A) color with channels expressed as plain numbers, convenient for further conversion or manipulation.
