Skip to main content

Props

PropTypeRequiredDescription
imagestringImage to crop. image or video is required.
videostring | Array<{ src: string; type?: string }>Video to crop. image or video is required.
crop{ x: number; y: number }yesMedia position. { x: 0, y: 0 } centers the media under the cropper.
zoomnumberZoom between minZoom and maxZoom. Defaults to 1.
rotationnumberRotation in degrees. Defaults to 0.
aspectnumberCrop area ratio. Defaults to 4 / 3.
minZoomnumberMinimum zoom. Defaults to 1.
maxZoomnumberMaximum zoom. Defaults to 3.
zoomWithScrollbooleanEnable scroll zoom. Defaults to true.
cropShape'rect' | 'round'Crop area shape. Defaults to 'rect'.
cropSize{ width: number; height: number }Fixed crop area size in pixels. Prefer aspect unless you really need fixed dimensions.
showGridbooleanShow third-line grid. Defaults to true.
roundCropAreaPixelsbooleanRound crop area dimensions to integer pixels. Defaults to false.
zoomSpeednumberMultiplies zoom changes. Defaults to 1.
objectFit'contain' | 'cover' | 'horizontal-cover' | 'vertical-cover'Controls how the media fits the cropper. Defaults to 'contain'.
restrictPositionbooleanRestrict media position to cropper boundaries. Useful when zoom < 1.
initialCroppedAreaPercentages{ width: number; height: number; x: number; y: number }Restore a crop from a previous croppedArea value. Preferred over pixels.
initialCroppedAreaPixels{ width: number; height: number; x: number; y: number }Restore a crop from a previous croppedAreaPixels value.
transformstringCustom CSS transform for the media.
style{ containerStyle?: object; mediaStyle?: object; cropAreaStyle?: object }Inline style overrides.
classes{ containerClassName?: string; mediaClassName?: string; cropAreaClassName?: string }Custom class names.
mediaPropsobjectProps passed to the image or video element.
cropperPropsobjectProps passed to the cropper container.
disableAutomaticStylesInjectionbooleanDisable automatic CSS injection.
setCropperRef(ref: React.RefObject<HTMLDivElement>) => voidReceives the cropper ref.
setImageRef(ref: React.RefObject<HTMLImageElement>) => voidReceives the image ref.
setVideoRef(ref: React.RefObject<HTMLVideoElement>) => voidReceives the video ref.
setMediaSize(size: MediaSize) => voidExposes media size for advanced restore helpers.
setCropSize(size: Size) => voidExposes crop size for advanced restore helpers.
noncestringNonce added to the injected style tag.
keyboardStepnumberPixels moved per arrow key press. Defaults to 1.