React Image Crop
A responsive image cropping tool for React
README
This documentation refers to v10. Go to 9.1.1 tag for v9 docs.
React Image Crop
An image cropping tool for React with no dependencies.

Table of Contents
1. Features
2. Installation
3. Usage
4. Example
5. CDN
6. Props
7. FAQ
Features
- Responsive (you can use pixels or percentages).
- Touch enabled.
- Free-form or fixed aspect crops.
- Fully keyboard accessible (a11y).
- No dependencies/small footprint (5KB gzip).
- Min/max crop size.
- Crop anything, not just images.
If React Crop doesn't cover your requirements then take a look at Pintura. It features cropping, rotating, filtering, annotation, and lots more.
Installation
- ```
- npm i react-image-crop --save
- yarn add react-image-crop
- ```
This library works with all modern browsers. It does not work with IE.
Usage
Include the main js module:
- ``` js
- import ReactCrop from 'react-image-crop'
- ```
Include either dist/ReactCrop.css or ReactCrop.scss.
- ``` js
- import 'react-image-crop/dist/ReactCrop.css'
- // or scss:
- import 'react-image-crop/src/ReactCrop.scss'
- ```
Example
- ```tsx
- function CropDemo({ src }) {
- const [crop, setCrop] = useState<Crop>()
- return (
- <ReactCrop crop={crop} onChange={c => setCrop(c)}>
- <img src={src} />
- </ReactCrop>
- )
- }
- ```
See the sandbox demo for a more complete example.
CDN
- ``` html
- <script src="https://unpkg.com/react-image-crop/dist/ReactCrop.min.js"></script>
- ```