0.0.32 • Published 9 months ago

react-iro v0.0.32

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

React Iro - A React Wrapper for iro.js

React Iro is an UNOFFICIAL open-source library that provides a React wrapper for iro.js, a versatile color picker library. With React Iro, you can easily integrate an interactive color picker into your React applications, allowing users to select colors for various elements and purposes.

Installation

You can install React Iro using npm:

npm install react-iro

Usage

To use React Iro in your React application, follow these steps:

  1. Import the component:
import ColorPicker from "react-iro"
  1. Define the color picker options and pass them as props:
const colorPickerOptions = {
  width: 200, // Width of the color picker
  color: "#ff0000", // Initial color
  // Other iro.js options can be added here
}
//Pass it to the component via the options props
<ColorPicker options={colorPickerOptions}/>

You can find all available options in the iro.js documentation.

Props

React Iro accepts the following props:

  • options: An object accepting all available options in the iro.js documentation.
  • setters: An object containing all the events available in the original component.
    • Currently accepts only onColorChange, which is the equivalent of "color:change". More events will be added soon!

Example

Here's a complete example of how to use React Iro:

import { useState } from "react"
import ColorPicker from "react-iro"
import iro from "@jaames/iro";

const Example = () => {
    const [color, setColor] = useState<string>()

    return <>
        {/*will use this svg for the custom handle */}
        <svg display={"none"}>
            <defs>
                <g id="handle" >

                    <circle cx='50%' cy='50%' r='10' stroke='#004175' stroke-width='3' fill='transparent' />

                </g>
            </defs>
        </svg>
        <ColorPicker
            setters={{
                onChangeColor: (color: iro.Color) => {
                    setColor(color.rgbaString.replaceAll("rgba", ""))
                },
            }}
            options={{
                //all this options are regular iro.js options
                color: "#f1be51",
                width: 300,
                height: 300,
                wheelLightness: false,
                layoutDirection: "horizontal",
                handleSvg: "#handle",
                layout: [
                    //define your layout according to original docs
                ],
            }}
        />
    </>

}

License

React Iro is open-source and licensed under the MIT License.

Acknowledgments

React Iro is based on the powerful iro.js library, and we extend our gratitude to the iro.js team for providing such a fantastic color picker solution.

0.0.32

9 months ago

0.0.31

9 months ago

0.0.30

9 months ago

0.0.28

9 months ago

0.0.27

9 months ago

0.0.26

9 months ago

0.0.25

9 months ago

0.0.24

9 months ago

0.0.23

9 months ago

0.0.22

9 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.18

9 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.15

9 months ago

0.0.1

9 months ago