Image Cropper

React image cropper with drag to pan, wheel and pinch zoom, aspect presets, a circular avatar mask and 90 degree rotation that returns the crop in source pixels.

src/registry/ui/image-cropper.tsx/r/image-cropper.json

Installation#

bash
npx shadcn@latest add https://ui.minidev.pro/r/image-cropper.json

Usage#

tsx
import { ImageCropper } from "@/components/ui/image-cropper"

export function Example() {
  return <ImageCropper />
}

API reference#

ImageCropper props
PropTypeDefault
srcstringSAMPLE_SRC
altstring"Lumen sample landscape"
aspectsAspect[]["1:1", "4:3", "16:9"]
defaultAspectAspect"4:3"
defaultCirclebooleanfalse
allowCirclebooleantrue
maxZoomnumber4
showPreviewbooleantrue
onCrop(rect: CropRect, info: { aspect: Aspect; circle: boolean }) => void-
fileNamestring"lumen-cover.png"
classNamestring-

Dependencies#

npm

lucide-reactmotion
All media and upload components