Skip to content
Eskais UI

Data

Image Cropper

UI SDK ImageCropper styled: a selection that dims the rest of the image with a grid while dragging and eight handles, or a round frame the image pans and zooms under, with zoom, rotate and flip, and cropImage.

Example

Mountains at sunset

Installation

npx shadcn@latest add @eskais/image-cropper
Brings alongbutton
npm packageslucide-react

Usage

Import
import {  createImageCropperController,  ImageCropper,  ImageCropperFlip,  ImageCropperGrid,  ImageCropperHandle,  ImageCropperImage,  ImageCropperRotate,  ImageCropperSelection,  ImageCropperViewport,  ImageCropperZoom,  imageCropperLabels,  cropImage,} from "@/components/ui/image-cropper"

Reach for it to crop an upload before saving: a cover image with a box, an avatar with mode="frame" and shape="circle".

API reference

ImageCropper

PropTypeDefault
altUsed only by the default layout, without children.string""
labelsPartial<ImageCropperLabels>–

Also takes every prop of UI SDK ImageCropper.

ImageCropperSelection

Takes every prop of UI SDK ImageCropperSelection.

Other exports

createImageCropperControllerimageCropperLabelscropImagetype CropImageOptionstype ImageCropperLabelstype ImageCropperPropstype ImageCroptype ImageCropperControllertype ImageCropperCropChangeReason

Accessibility

  • The selection is a slider: arrow keys move it, and R rotates, Shift+R back.
  • Zoom is a range input; rotate and flip are buttons with visible labels.
  • Until the image loads, the group is aria-busy and nothing can change.

Agent actions

Agents find it by its label and set the crop or the zoom.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.