Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Image Cropper for React Radix UI

Crop and transform images.

Framework
UI library

Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/image-cropper.json

Anatomy

ImageCropper
├── ImageCropperViewport
├── ImageCropperImage
├── ImageCropperSelection
├── ImageCropperHandle
└── ImageCropperGrid

Usage

import {
  ImageCropper,
  ImageCropperImage,
  ImageCropperSelection,
} from "@/components/ui/image-cropper";
<ImageCropper className="aspect-video w-full max-w-lg">
  <ImageCropperImage
    alt="Crop me"
    src="https://images.unsplash.com/photo-1662692735672-544412d65934?w=600&auto=format"
  />
  <ImageCropperSelection />
</ImageCropper>

Demos

Aspect Ratio

Circle Crop

Controlled Zoom

Fixed Crop Area

Initial Crop

Min Max Size

Zoom Limits

API Reference

ImageCropper

div

PropType
AttributeType
CSS variableType
--color-whitestring
--crop-heightstring
--crop-widthstring
--crop-xstring
--crop-ystring
--image-offset-xstring
--image-offset-ystring
--image-rotationstring
--image-zoomstring

ImageCropperViewport

div

PropType
AttributeType
CSS variableType
--color-whitestring

ImageCropperImage

img

PropType
AttributeType

ImageCropperSelection

div

PropType
AttributeType
CSS variableType
--cropper-accentstring

ImageCropperHandle

div

PropType
AttributeType
CSS variableType
--cropper-accentstring
--cropper-handler-sizestring
--cropper-handler-widthstring

ImageCropperGrid

div

PropType
AttributeType

useImageCropper