3.0.0 • Published 7 months ago

@super-effective/react-color-picker v3.0.0

Weekly downloads
351
License
MIT
Repository
github
Last release
7 months ago

react-color-picker

A React color picker component

Screenshot

Install

NPM:

npm install @super-effective/react-color-picker

Yarn:

yarn add @super-effective/react-color-picker

Usage

Import the component:

import ReactColorPicker from '@super-effective/react-color-picker';

Render the component in your code:

<ReactColorPicker color={color} onChange={onColorChange} /

Props

PropTypeDetails
classNamestringThe class name to put on the container div
colorstringThe initial/current selected color (hex value, e.g. #ff00ff)
showSwatchboolWhether the selected color swatch should be displayed below the picker
showHexboolWhether the hex value input should be displayed below the picker
onChangefuncThe callback function to be called when the color value changes
onInteractionStartfuncThe callback function to be called when interaction starts with one of the value selectors
onInteractionEndfuncThe callback function to be called when interaction ends with one of the value selectors

Example

See the included example for reference

import React, { useState } from 'react';
import ReactColorPicker from '@super-effective/react-color-picker';

import styles from './App.module.scss';

const App = () => {
  const [color, setColor] = useState('#3cd6bf');
  const [isInteracting, setIsInteracting] = useState(false);

  const onColorChange = (updatedColor) => {
    setColor(updatedColor);
  };

  const onInteractionStart = () => {
    setIsInteracting(true);
  };

  const onInteractionEnd = () => {
    setIsInteracting(false);
  };

  return (
    <div className={styles.app}>
      <h1>
        Selected color:
        {color}
      </h1>
      <p>
        Is interacting?
        &nbsp;
        {isInteracting ? 'Yes' : 'No'}
      </p>
      <div className={styles.color_picker}>
        <ReactColorPicker
          color={color}
          onChange={onColorChange}
          onInteractionStart={onInteractionStart}
          onInteractionEnd={onInteractionEnd}
        />
      </div>
    </div>
  );
};

export default App;
3.0.0

7 months ago

2.1.3

2 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago