Cropper

An image cropper built on react-easy-crop. Drag to reposition, pinch / scroll / slider to zoom — the image always covers the crop area. Call getCroppedImage() through a ref to render the crop to a JPEG data URL via canvas (same-origin / CORS images only).

As a dialog

CropperDialog is the full two-step photo flow: a drop zone to pick or drop a photo, then the crop step with the zoom slider, Save and Choose another photo. File state lives inside the dialog — the parent receives the cropped data URL via onSave and closes the dialog when its own work is done. Pass error (+ onClearError) to surface a validation alert on the crop step, and onRemove to offer removing the current photo. All copy is overridable via labels (the avatar flow passes translations through @repo/features/users/components/avatar-photo-dialog).

Cropper props

PropTypeDefaultDescription
srcstringURL or object URL of the image.
aspectnumber1Crop aspect ratio.
shape"round" | "rect""round"Crop mask shape.
outputSizenumber512Width (px) of the output; height follows the aspect.
refRef<CropperHandle>Exposes getCroppedImage() (async) and reset().

CropperDialog props

PropTypeDefaultDescription
onSave(dataUrl: string) => voidReceives the cropped JPEG data URL.
savingbooleanfalseDisables actions and shows the saving label.
errorstring | nullExternal validation error shown on the crop step.
onRemove() => voidAdds a remove action for the current photo.
maxSizeMbnumber10Max accepted file size.
labelsPartial<CropperDialogLabels>Override any copy (title, hints, buttons).

On this page