Composables
ComposableOriginal

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

Use mouse wheel or pinch gesture to zoom. Drag with mouse or touch, or use arrow keys to pan the image within the crop area.

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.

Try different aspect ratio presets including circle crop

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

Adjust the crop area to see live preview

Aspect Ratio

Crop Preview

Crop preview will appear here
Adjust the crop area above

Download Cropped Image

Use createCropCanvas and downloadCroppedImage to export the crop as a file.

Crop the image and download the result

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

Crop for Instagram Post - 1080×1080
Instagram Post
1080×1080

Preset Selection

Export

image-instagram-post.png

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.

Prop

CropperZoomControls

Zoom out, zoom in, and optional reset buttons. Renders a custom toolbar.

Prop

CropperAspectRatioControls

Row of preset buttons for switching the crop ratio.

Prop

CropperInfo

Read-only summary of zoom, aspect, and crop size.

Prop

CropperActions

Optional download and export buttons.

Prop

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

Prop

Returns

PropertyTypeDescription
zoomnumberCurrent zoom level.
aspectRationumberCurrent aspect ratio.
cropDataCropData | undefinedLatest crop metadata from onCropChange.
setZoom(zoom: number) => voidSets zoom, clamped to minZoom/maxZoom.
setAspectRatio(ratio: number) => voidSets the aspect ratio.
onCropChange(cropArea: Area | null) => voidHandler to pass to Cropper.
reset() => voidResets 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.