Skip to content

pantoken-root / plugins/pantoken/custom-theme-colors/src / parseHexColor

Function: parseHexColor() ​

parseHexColor(input): string

Beta

Validate and normalise a user-supplied hex colour. This is the only entry point for untrusted input into generated CSS, so anything but #rgb/#rrggbb is rejected.

Parameters ​

input ​

string

A hex colour, with or without the leading #.

Returns ​

string

Lowercase #rrggbb.

Throws ​

TypeError when input isn't a 3- or 6-digit hex colour.