Skip to content

elliothux/ReactColorPicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reactColorPicker

A light and simple color picker for react.

Installation

npm install reactcolorpicker --save

or

yarn add reactcolorpicker

Usage

import React from 'react';
import Picker from 'reactcolorpicker';

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.setColor = this.setColor.bind(this);
        this.state = {
            RGB: [0, 0, 0],
            HSL: [360, 1, 0],
            HEX: '#000'
        }
    }
    
    // Execute this method every time a color is picked
    setColor(color) {
        this.setState({
            RGB: [color.R, color.G, color.B],
            HSL: [color.H, color.S, color.L],
            HEX: color.HEX
        });
        console.log('Color updated!')
    }
    
    render() {return(
        <div>
            <h2 style={{color: this.state.HEX}}>
                Please pick your color:
            </h2>
            <Picker getValue={this.setColor}/>
        </div>
    )}
}

About

🎨 A simple color picker for React

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published