Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fav-color-picker-react

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fav-color-picker-react

color picker component with favourites color list that return color object having all properties that any developer required in coding. As rgb, rgba, hsl, hsla, hex, r, g, b, a, h, s, l, etc. color code.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Fav Color Picker React

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


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
mousedown
mousemove
mouseup
when mouse action on color-picker, hue and alpha slider
touchstart
touchmove
touchend
when 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']}
/>

NOTE : for TypeScript onChange event argument type must be specify :colorPickerChangeResult
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

Keywords

FAQs

Package last updated on 03 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc