parseColor

Commons
stable

Normalise any supported color representation — integer, CSS string (hex, rgb, rgba, hsl, hsla, hsv, hsva), or an RGBA/HSLA/HSVA object — into a unified `TRGBA` object.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

color
required
TColorType
Any color value accepted by the design system: a 24-bit integer (0x000000–0xFFFFFF), a CSS color string (`"#rrggbb"`, `"rgb(…)"`, `"hsl(…)"`, etc.), or a plain `{r,g,b}` / `{h,s,l}` / `{h,s,v}` object.

API

Return value

The value returned by this util.

A normalised `{ r, g, b, a? }` object with channel values in the range 0–255 (and `a` in 0–1).

Usage

Examples

Ready-to-paste usage snippets.

Parse various color formats

typescript