Workspace
CropArea
A picture with a controlled crop hole and drag handles
60, 40, 120 × 120
Usage
import { useState } from "react";
import { CropArea, CropRect } from "@gpuixui/media";
const [crop, setCrop] = useState(
new CropRect({ x: 60, y: 40, width: 100, height: 100 }),
);
<CropArea
src={picture}
alt="The picture being cropped"
width={240}
height={160}
value={crop}
onChange={setCrop}
aspectRatio={1}
guides
label="Crop the thumbnail"
/>;API
| Prop | Type | Default |
|---|---|---|
src | string | required (blank paints no picture; a non-text value paints none too) |
alt | string | required (a blank or non-text value reads as "Picture") |
width | number | required |
height | number | required |
value | CropRect | required (an absent value reads as the origin at the smallest side) |
onChange | (crop: CropRect) => void | required |
minSize | number | 24 |
handleSize | number | 10 |
aspectRatio | number (width / height) | — (free) |
guides | boolean | false |
label | string | "Crop area" (a blank name reads as the default) |
disabled | boolean | false |
className | string | — |
style | StyleDesc | — |
Edit this page on GitHubpackages/media/docs/crop-area.mdx