RGBtoCSS

Color
stable

Serialize an sRGB object to a CSS rgb() or rgba() string. Emits rgba() only when the alpha property is defined.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

{r, g, b, a}
required
TRGBA

API

Return value

The value returned by this util.

"rgb(r, g, b)" when alpha is undefined; "rgba(r, g, b, a)" when alpha is provided.

Usage

Examples

Ready-to-paste usage snippets.

Opaque and semi-transparent colours

typescript