https://github.com/scriptex/react-dropper
Pick a color from any image in React
https://github.com/scriptex/react-dropper
colorpicker react-component
Last synced: 10 months ago
JSON representation
Pick a color from any image in React
- Host: GitHub
- URL: https://github.com/scriptex/react-dropper
- Owner: scriptex
- License: mit
- Created: 2019-04-21T05:32:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T01:57:25.000Z (over 1 year ago)
- Last Synced: 2024-05-02T06:13:51.792Z (over 1 year ago)
- Topics: colorpicker, react-component
- Language: TypeScript
- Homepage: https://react-dropper.atanas.info
- Size: 8.28 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/scriptex/react-dropper)
[](https://github.com/scriptex/react-dropper/actions?query=workflow%3ABuild)
[](https://www.codacy.com/gh/scriptex/react-dropper/dashboard?utm_source=github.com&utm_medium=referral&utm_content=scriptex/react-dropper&utm_campaign=Badge_Grade)
[](https://codebeat.co/projects/github-com-scriptex-react-dropper-master)
[](https://www.codefactor.io/repository/github/scriptex/react-dropper)
[](https://deepscan.io/dashboard#view=project&tid=3574&pid=5257&bid=40799)
[](https://github.com/scriptex/react-dropper/)
# React Dropper
> Pick a color from any image in React
## Visitor stats




## Code stats





## Install
```sh
npm i react-dropper
# or
yarn add react-dropper
```
## Demo
This component allows you to pick any color from any image rendered in a React application. See [the demo here](https://react-dropper.atanas.info).
## Usage
```javascript
import React from 'react';
import { Dropper } from 'react-dropper';
import MyImage from '../images/image.jpg';
ReactDOM.render(
{
// The color is the selected color
// The event is the event type - click, mousemove, etc
}}
/>,
document.getElementById('demo')
);
```
## Props
| Prop | Type | Required | Default | Description |
| ----------- | ---------- | -------- | ---------------------------------------- | --------------------------------------------------------------------- |
| `image` | `string` | true | '' | URL of the image asset (JPG or PNG) -CORS enabled for external assets |
| `width` | `number` | false | 300 | Width of the canvas area (in px) |
| `height` | `number` | false | 150 | Height of the canvas area (in px) |
| `className` | `string` | false | 'react-dropper' | CSS classname for the rendered element |
| `onChange` | `function` | false | (color: string, type: string) => unknown | An optional function which accepts two arguments |
The `onChange` function accepts two arguments:
- `color`: the selected color
- `type`: the type of the event - 'click', 'mousemove', etc. Useful when deciding whether you want to store the color or not.
## LICENSE
MIT
---
Connect with me:
---