Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
metadata
id: api-onChange
title: onChange

Pass a function to call every time the color is changed. Use this to store the color in the state of a parent component or to make other transformations.

Keep in mind this is called on drag events that can happen quite frequently. If you just need to get the color once use onChangeComplete.

import React from 'react';
import { SwatchesPicker } from 'react-color';

class Component extends React.Component {

  handleChange(color, event) {
    // color = {
    //   hex: '#333',
    //   rgb: {
    //     r: 51,
    //     g: 51,
    //     b: 51,
    //     a: 1,
    //   },
    //   hsl: {
    //     h: 0,
    //     s: 0,
    //     l: .20,
    //     a: 1,
    //   },
    // }
  }

  render() {
    return <SwatchesPicker onChange={ this.handleChange } />;
  }
}