Skip to content
caliper ui pro docs

Image crop

Crop an image before it is uploaded. Drag the frame to move it and a handle to resize it; a rule-of-thirds grid shows while you work. A fixed shape keeps only the corner handles, and every move works from the keyboard.

Pro
Terrace by the water

Drag the frame or a handle

When to use

  • Avatars, covers and product photos that must fit a known shape.
  • Trimming a screenshot or scan before it is attached.

When not to use

  • Editing beyond the crop (rotate, filters); that is a media editor.
  • Images the canvas cannot read: cross-origin files without CORS cannot be exported.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/image-crop

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

API reference

ImageCrop

7 props
PropTypeDefaultDescription
src *string—
alt *string—
aspectnumber—Pixel width / height to keep, e.g. 1 or 16 / 9. Leave out for a free crop.
cropCropRect—
onCropChange((crop: CropRect) => void)—
onImageLoad((image: HTMLImageElement) => void)—The loaded image, for `cropImage`.
classNamestring—

cropImage

0 props

No props of its own; it accepts the native props of its root element.

centredCrop

0 props

No props of its own; it accepts the native props of its root element.

resizeCrop

4 props
PropTypeDefault
x *number—
y *number—
width *number—
height *number—

Keyboard

  • No custom key handling; Tab and the native activation keys do the work.

Accessibility

It exposes group and button semantics, with aria-roledescription and aria-label kept in step with state.

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/image-crop.md

The index of every part is at /llms.txt.

More in Files