hslToCss
Formats an HSL(A) color as a CSS hsl() value, in the modern space-separated syntax.
The hue is wrapped into 0-360, saturation and lightness are clamped to 0-100, all three rounded to 1 decimal place; 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 | HslColor | The color to format. `a` defaults to 1 (opaque) when omitted. |
Returns
Section titled “Returns”string — hsl(h s% l%), or hsl(h s% l% / a) when translucent
Examples
Section titled “Examples”Opaque color
Section titled “Opaque color”The alpha is left out.
Translucent color with a negative hue
Section titled “Translucent color with a negative hue”The hue is wrapped into 0-360 and the alpha comes after a slash.
Related Types
Section titled “Related Types”HslColor
Section titled “HslColor”An HSL(A) color with channels expressed as plain numbers.
