Skip to content

berezh/jolor

Repository files navigation

Jolor

JavaScript color converter to HEX, RGB, RGBA, HSL

Install

npm install jolor

IsColor

Checks if a string is HTML colors value

import { isColor } from 'jolor';

isColor('white');
isColor('#888');
isColor('#f1f1f1');
isColor('rgb(0,100,255)');
isColor('hsl(100,50%,80%)');
//=> true

Color converting

import { toHex, toRgb, toRgba, toHsl } from 'jolor';

toHex('deepskyblue');
toHex(0, 191, 255);
toHex([0, 191, 255]);
toHex('rgb(0,191,255)');
toHex('hsl(195,100%,50%)');
//=> '#00bfff'

#00bfff

toRgb('indigo');
toRgb(75, 0, 130);
toRgb([75, 0, 130]);
toRgb('#4b0082');
//=> 'rgb(75,0,130)'

toRgb('hsl(275, 100%, 25%)');
//=> 'rgb(74, 0, 128)'

#4b0082

toRgba('sandybrown');
toRgba('rgb(244,164,96)');
toRgba('#f4a460');
//=> 'rgba(244,164,96,1)'

toRgba([244, 164, 96, 0.1]);
toRgba(244, 164, 96, 0.1);
//=> 'rgba(244,164,96,0.1)'

toRgba('hsl(28, 87%, 67%)');
//=> 'rgba(244,166,98,1)'

#f4a460

toHsl('purple');
toHsl([128, 0, 128]);
toHsl(128, 0, 128);
toHsl('rgb(128,0,128)');
toHsl('#800080');
//=> 'hsl(300,100%,25%)'

#800080

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published