ReferenceUtilitiesFunction
color()
Converts a CSS color string to an Oklab color.
function color(input: string | Color): Color;Converts a CSS color string to a Color.
Accepts hex colors (#f00, #ff5a5f, #ff000080) and the rgb()/rgba(),
hsl()/hsla(), oklab() and oklch() functions. A Color passed in is returned unchanged.
Note that named colors are not supported, to minimize bundle size. In particular, transparent
is not a valid color input.
Parameters
Section titled “Parameters”inputstring|ColorA CSS color string, or an existing color.
Returns
Section titled “Returns”ColorThe Oklab color.
Throws
Section titled “Throws”- PartyJSError
If the string isn’t a supported color.
Example
Section titled “Example”const cornflowerblue = color("#6495ed");