Skip to Content
Data & Media@hacline/ui/image-cropper

ImageCropper

Pan, zoom, and rotate a crop region over an image.

Usage

Drag the selection or resize the bottom-right handle, and adjust zoom or rotation. Current dimensions come from the image pixel coordinates provided by onCropChange, and cropImage exports the selection as a file.

Lake nestled between mountains

Exporting a Circular Avatar

Use shape="circle" to display a circular crop selection, then call cropImage to generate a PNG with transparent corners.

Lake photo used for avatar

Parts

PartDescription
ImageCropperFlip
A button that mirrors the image, left to right or, with direction="vertical", top to bottom.
ImageCropperGrid
Lines across the selection in thirds, for CSS to draw, with data-dragging during a drag.
ImageCropperHandle
An edge or corner of the selection, by its position, that resizes it in a box.
ImageCropperImage
The image, from the root's src, turned and flipped. Give it an alt.
ImageCropperRotate
A button that turns the image a quarter clockwise.
ImageCropperSelection
The crop. A pointer drags it in a box; arrows move it, plus and minus zoom, and R turns the image.
ImageCropperViewport
The area the image shows in. Give it a size; its padding keeps the image off its edges. In a frame, a pointer pans the image and the wheel zooms it.
ImageCropperZoom
A range input for the zoom, from 1 to maxZoom.

Props

Prop

Type

View parts and state attributes in UI SDK.

The lake photo used in the examples is from Unsplash.