1.0.2 • Published 2 years ago

fav-color-picker-react v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Fav Color Picker React

color picker component with favourites color list that return color object having all properties that any developer required in coding.

npm.io

View Demo

codesandbox-example

ghpages-example

gitHub-SourceCode

How to install

npm install fav-color-picker-react

How to import

import ColorPicker from "fav-color-picker-react";

How to use

<ColorPicker/>;

Props

propertytypedefault valueDescription
colorstring"Red"any valid string color value.
widthnumber300width of color palette
heightnumber200height of color palette
favouritesarray of strings List of favourite colors that user can select

onChange Event

<ColorPicker onChange={(e)=>{console.log(e.color,e.type)}}/>

onChange event handler argument e.color value

PropertyDescription < ColorObject >
.nameName of color defined in css3
.rgbString rgb color value
.rgbaString rgba color value
.hexString Hexa code of color
.hexaString Hexa code of color with alpha value
.hslString HSL color
.hslaString HSL color with alpha value
.rNumeric Red Value
.gNumeric Green Value
.bNumeric Blue Value
.aNumeric Alpha Value Floating Point
.hNumeric Hue Value
.sNumeric Saturation Value
.lNumeric Lightness Value
.strString that is passed for conversion of color
.isValidtrue if passed string is valid color string or valid html colorName.

onChange event handler argument e.type value

valuedescription
mousedownmousemovemouseupwhen mouse action on color-picker, hue and alpha slider
touchstarttouchmovetouchendwhen touch action on color-picker, hue and alpha slider
rgbchangewhen rgb textbox value change

Example - 2

import ColorPicker, { colorPickerChangeResult, ColorObject } from "fav-color-picker-react";

<ColorPicker
    color='red'
    width={300}
    height={150}
    onChange={(e: colorPickerChangeResult) => {
        document.body.style.backgroundColor=e.color.rgba;
    }}
    favourites={['red', 'yellow', 'green', 'cyan', 'blue', 'magenta', 'pink', 'white', 'silver', 'gray', 'maroon', 'black']}
/>
type colorPickerChangeResult = {
    color: ColorObject;
    type: string;
};

View Demo

codesandbox-example

ghpages-example

gitHub-SourceCode

License Free to use

Author

developergovindgupta (Govind Prasad Gupta)

Email : govindprasadguptamca@gmail.com