Image Cropper
UI SDK ImageCropper styled: a selection that dims the rest of the image with a grid while dragging and eight handles, or a round frame the image pans and zooms under, with zoom, rotate and flip, and cropImage.
Example
image-cropper-demo.tsxCopy code
Installation
Copy code
Brings alongbutton
npm packages
lucide-reactUsage
ImportCopy code
Reach for it to crop an upload before saving: a cover image with a box, an avatar with mode="frame" and shape="circle".
API reference
ImageCropper
| Prop | Type | Default |
|---|---|---|
altUsed only by the default layout, without children. | string | "" |
labels | Partial<ImageCropperLabels> | – |
Also takes every prop of UI SDK ImageCropper.
ImageCropperViewport
ImageCropperImage
ImageCropperSelection
ImageCropperGrid
ImageCropperHandle
ImageCropperZoom
ImageCropperRotate
ImageCropperFlip
Other exports
createImageCropperControllerimageCropperLabelscropImagetype CropImageOptionstype ImageCropperLabelstype ImageCropperPropstype ImageCroptype ImageCropperControllertype ImageCropperCropChangeReasonAccessibility
- The selection is a slider: arrow keys move it, and R rotates, Shift+R back.
- Zoom is a range input; rotate and flip are buttons with visible labels.
- Until the image loads, the group is aria-busy and nothing can change.
Agent actions
Agents find it by its label and set the crop or the zoom.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.