Color Regex
color-regex
Easily check the format of any color. Use diverse color helpers available to verify any color.
Installation
npm install color-regex
Usage
const Color = ; Color; // "hex"Color; // "rgb"Color; // trueColor; // trueColor; // [ '255', '100', '50' ]Color; // [ '230', '100%', '50%' ]Color; // [ '320', '100', '44', '0.7' ]
Supported formats
keyword
Example:"red"
(black,white,red,green,yellow,magenta,cyan,gray,etc)hex
Example:"#FFF000"
rgb
Example:"rgb(255, 255, 255)"
rgba
Example:"rgba(255, 255, 255, 0.3)"
hsl
Example:"hsl(0, 100%, 50%)"
hsla
Example:"hsla(0, 100%, 50%, 0.8)"
hsv
Example:"hsv(330, 93%, 98%)"
hwb
Example:"hwb(0, 100%, 0%)"
Examples
const Color = ; //Get color formatconsole; // "keyword"console; // "hex"console; // "rgb"console; // "rgba"console; // "hsl"console; // "hsla"console; // "hsv"console; // "hwb" // Check color formatconsole; // trueconsole; // trueconsole; // trueconsole; // trueconsole; // trueconsole; // trueconsole; // trueconsole; // true //Clear format and spacesconsole; // "255,100,50"console; // "255,100,50,0.3"console; // "230,100%,50%"console; // "320,100%,44%,0.7" //To array, set true to remove symbolsconsole; // [ '255', '100', '50' ]console; // [ '255', '100', '50', '0.3' ]console; // [ '230', '100%', '50%' ]console; // [ '320', '100', '44', '0.7' ]
Collaborators
Thanks
License
MIT