antd-img-crop
Version:
An image cropper for Ant Design Upload
51 lines (36 loc) • 2.41 kB
Markdown
# antd-img-crop
An image cropper for Ant Design [Upload](https://ant.design/components/upload/).
[](https://www.npmjs.com/package/antd-img-crop)
[](https://www.npmtrends.com/antd-img-crop)
[](https://bundlephobia.com/result?p=antd-img-crop)
[](https://github.com/nanxiaobei/antd-img-crop/blob/master/LICENSE)
English | [简体中文](./README.zh-CN.md)
## Demo
[](https://codesandbox.io/s/antd-img-crop-4qoom5p9x4?fontsize=14)
## Install
```sh
yarn add antd-img-crop
```
## Usage
```jsx harmony
import ImgCrop from 'antd-img-crop';
import { Upload } from 'antd';
const Demo = () => (
<ImgCrop>
<Upload>+ Add image</Upload>
</ImgCrop>
);
```
## Props
| Prop | Type | Default | Description |
| ---------- | -------------------- | -------------- | --------------------------------------------------------------- |
| aspect | `number` | `1 / 1` | Aspect of the crop area , `width / height` |
| shape | `string` | `'rect'` | Shape of the crop area, `'rect'` or `'round'` |
| grid | `boolean` | `false` | Show grid of the crop area (third-lines) |
| zoom | `boolean` | `true` | Enable zoom for the image |
| rotate | `boolean` | `false` | Enable rotate for the image |
| beforeCrop | `function` | - | Called before the model open, if return `false`, it'll not open |
| modalTitle | `string` | `'Edit image'` | Title of the modal |
| modalWidth | `number` \| `string` | `520` | Width of the modal in pixels or percentages |
## License
[MIT License](https://github.com/nanxiaobei/antd-img-crop/blob/master/LICENSE) (c) [nanxiaobei](https://mrlee.me/)