Cropper
Image cropping tool with zoom, rotation, and customizable aspect ratios
The cropper lets users pan and zoom an image inside a fixed crop frame, then export the result. Use it for avatar uploads, cover images, and any flow that needs a constrained crop with optional aspect-ratio presets.
Preview
Simple cropper - no controls, no state
Installation
Usage
Composition
Cropper holds the image and crop frame. The control components render alongside it and drive state through the useCropper hook.
Examples
Aspect Ratios
Pass aspectRatio to constrain the crop frame to a fixed ratio.
Aspect Ratio
With Preview
Read onCropChange to render a live preview of the cropped result.
Live Preview Cropper
See your crop result update in real-time as you adjust the selection
Original Image
Aspect Ratio
Crop Preview
Download Cropped Image
Use createCropCanvas and downloadCroppedImage to export the crop as a file.
Export Options
Download your cropped image as PNG
Pro Features
Combine aspect-ratio presets, circular crops, and custom dimensions for a full editor.
Professional Image Cropper
Upload, crop, and export for social media platforms with advanced controls
Preset Selection
Export
API Reference
The image surface (Cropper, CropperImage, CropperCropArea, CropperCropAreaCircular, CropperDescription) is built on top of @origin-space/image-cropper. Its props pass through to that library. The control parts (CropperControls, CropperZoomControls, CropperAspectRatioControls, CropperInfo, CropperActions) are custom, and useCropper wires them together.
Props
Cropper
Pan-and-zoom image surface and crop frame. Wraps the cropper library's Root.
CropperZoomControls
Zoom out, zoom in, and optional reset buttons. Renders a custom toolbar.
CropperAspectRatioControls
Row of preset buttons for switching the crop ratio.
CropperInfo
Read-only summary of zoom, aspect, and crop size.
CropperActions
Optional download and export buttons.
Hooks
useCropper
Manages zoom, aspect ratio, and crop state for a Cropper, and wires up the control parts. Pass setZoom/zoom to CropperZoomControls, setAspectRatio/aspectRatio to CropperAspectRatioControls, and onCropChange to Cropper.
Options
Returns
| Property | Type | Description |
|---|---|---|
zoom | number | Current zoom level. |
aspectRatio | number | Current aspect ratio. |
cropData | CropData | undefined | Latest crop metadata from onCropChange. |
setZoom | (zoom: number) => void | Sets zoom, clamped to minZoom/maxZoom. |
setAspectRatio | (ratio: number) => void | Sets the aspect ratio. |
onCropChange | (cropArea: Area | null) => void | Handler to pass to Cropper. |
reset | () => void | Resets zoom and aspect ratio to their initial values. |
exportCrop | (image, filename?) => Promise<{ canvas; blob; dataUrl } | null> | Renders the current crop to a canvas, optionally downloading it. |
config | { minZoom; maxZoom; zoomStep } | Resolved zoom bounds and step. |
Utilities
createCropCanvas
Draws the cropped region of image to a canvas. Pass isCircular to clip the output to a circle.
downloadCroppedImage
Triggers a browser download of the canvas as a PNG. filename defaults to "cropped-image.png".
getCroppedImageBlob
Resolves the canvas contents as a Blob, useful for uploading the crop.