---
title: "Image Cropper"
description: "Pick the part of a picture to keep: 8 handles or a fixed circle, zoom, straighten, turns, flips, aspect presets, and full keyboard support."
url: https://gelatinui.com/components/image-cropper
markdown_url: https://gelatinui.com/components/image-cropper.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/image-cropper"
version: "2026-11-15"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Image Cropper

> Pick the part of a picture to keep: 8 handles or a fixed circle, zoom, straighten, turns, flips, aspect presets, and full keyboard support.

Page: https://gelatinui.com/components/image-cropper

## When to use it

Best for: Pick the part of a picture to keep: move, zoom, turn, flip, and export the crop as a file.

- Use it to let people pick the part of a picture to keep.
- Use `variant="circle"` for an avatar. The aspect is then 1:1.
- Use `ImageCropperAspectGroup` when people choose the ratio, or set `aspect` to "16:9".
- Use `ImageCropperRotateSlider` to straighten a photo, and `ImageCropperRotateButton` for 90° turns.
- Use `readOnly` to show the crop during a save.

## When not to use it

- To only show a picture, use an [Image](https://gelatinui.com/components/image.md).
- To add files with no crop, use a [Dropzone](https://gelatinui.com/components/dropzone.md).

## Notes for agents

- Give `ImageCropperViewport` a height, such as `h-75` or `aspect-[4/3]`. It fills its parent.
- Import `useImageCropper` from `hooks/use-image-cropper`. It gives `getCropData` and `getCroppedImage` to a part inside the cropper.
- `getCroppedImage` rejects when the browser cannot read the picture. Show that message.
- `crossOrigin` is `anonymous` by default, so a host with no CORS header fails to load. Pass `null` to show the picture; only the export then fails.
- `onCropChange` gives natural pixels, 120ms after each change stops.
- With no `src`, an `ImageCropperEmpty` child shows the empty state.
- Keep the `labels` object stable.
- `ImageCropperAspectGroup` is disabled for a circle.

## Anatomy

```text
ImageCropper
├─ ImageCropperViewport (0..n)
├─ ImageCropperEmpty (0..n)
├─ ImageCropperImage (0..n)
├─ ImageCropperArea (0..n)
├─ ImageCropperGrid (0..n)
├─ ImageCropperHandle (0..n)
├─ ImageCropperZoomSlider (0..n)
├─ ImageCropperRotateSlider (0..n)
├─ ImageCropperRotateButton (0..n)
├─ ImageCropperFlipButton (0..n)
├─ ImageCropperReset (0..n)
└─ ImageCropperAspectGroup (0..n)
```

## API reference

### ImageCropper

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `src` | `string \| Blob` |  | The picture: a URL or a file (a `Blob` from a Dropzone). No `src`: the empty state. |
| `crossOrigin` | `"anonymous" \| "use-credentials" \| null` | "anonymous" | The CORS mode of the `<img>`. `anonymous` (default) keeps a picture from a CDN with CORS headers readable, so the export works; a host with no CORS header then fails to load (the error state). `null` loads with no CORS mode: a picture from any host shows, and only the export fails with a clear message (the canvas is tainted). |
| `variant` | `ImageCropperVariant` | "rect" | `rect` (default) or `circle` (an avatar; the aspect is 1:1). |
| `fixedCropArea` | `boolean` |  | The crop stays fixed and the picture moves under it. Default: `true` for a circle. |
| `aspect` | `string` |  | The aspect: `free`, `original`, or a ratio text ("16:9"). Controlled with `onAspectChange`. |
| `defaultAspect` | `string` |  |  |
| `onAspectChange` | `function` |  |  |
| `zoom` | `number` |  | The zoom, 1 = the base fit. Controlled with `onZoomChange` (called when a change settles). |
| `defaultZoom` | `number` |  |  |
| `onZoomChange` | `function` |  |  |
| `rotation` | `number` |  | The turn in degrees (quarter turns plus the fine straighten). |
| `defaultRotation` | `number` |  |  |
| `onRotationChange` | `function` |  |  |
| `flip` | `ImageCropperFlip` |  |  |
| `defaultFlip` | `ImageCropperFlip` |  |  |
| `onFlipChange` | `function` |  |  |
| `onCropChange` | `function` |  | The crop in natural pixels, 120ms after each change stops. |
| `onStatusChange` | `function` |  |  |
| `minZoom` | `number` | 1 | Default 1 and 4. |
| `maxZoom` | `number` | 4 |  |
| `disabled` | `boolean` | false | No input, 50%, no handles. |
| `readOnly` | `boolean` | false | The crop shows (a preview, a save in progress) but nothing moves; the area stays focusable. |
| `size` | `ImageCropperSize` | "default" | The size of the control row: 28, 32 (default), or 36px buttons; 44px on touch. |
| `labels` | `Partial<ImageCropperLabels>` |  | Every text; keep the object stable. |
| `children` | `ReactNode` |  |  |

### ImageCropperViewport

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ImageCropperEmpty

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ImageCropperImage

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  | The classes of the `<img>`. |
| `decoding` | `"async" \| "auto" \| "sync"` |  |  |
| `fetchPriority` | `"auto" \| "high" \| "low"` |  |  |
| `referrerPolicy` | `HTMLAttributeReferrerPolicy` |  |  |
| `alt` | `string` | "" | The text of the picture; default `""`, because the viewport group already names the task. |

### ImageCropperArea

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ImageCropperGrid

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ImageCropperHandle

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `position` | `CropperHandle` |  | Which corner or edge it moves. |

### ImageCropperZoomSlider

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ImageCropperRotateSlider

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `onValueCommitted` | `function` |  | The value at the end of a drag (after the flick), a key press, or a reset. |
| `onMovingChange` | `function` |  | `true` from the press until a flick stops: a host can show a grid while the ruler moves. |
| `step` | `number` |  | The value grid and the arrow-key step. Default `1`. |
| `largeStep` | `number` |  | Shift + arrow and Page Up or Down. Default 10 steps. |
| `tickStep` | `number` |  | The value of one tick (6px). Default: `step`. |
| `majorEvery` | `number` |  | A major (long) tick each this many ticks, counted from 0. Default `5`. |
| `origin` | `number \| "center" \| "start"` |  | The value with the dot, where a drag holds for 6px: `center` (0, kept inside the range), a number, or `start` (no dot; the span grows from `min`). Default `center`. |
| `resetValue` | `number` |  | The value of a reset. Default: `defaultValue`, else the origin. |
| `labels` | `boolean \| ((value: number) => string)` |  | Numbers on the ticks: `true` (the formatted value), or a function. Not on `vertical`. The arc is made for up to 250 ticks: past half a turn of its circle the ticks overlap. |
| `labelEvery` | `number` |  | A label each this many ticks. Default `majorEvery × 2`. |
| `variant` | `RulerSliderVariant` |  | `straight` (default), `arc` (a curved ruler), or `vertical` (higher values up). |
| `size` | `RulerSliderSize` |  |  |
| `format` | `NumberFormatOptions` |  | The number format of the value, the labels, and `aria-valuetext`. |
| `locale` | `LocalesArgument` |  |  |
| `invalid` | `boolean` |  | Shown as invalid (an invalid `Field` around it does the same). |
| `name` | `string` |  |  |
| `form` | `string` |  |  |
| `aria-label` | `string` |  | The name of the slider when there is no `RulerSliderLabel`. |
| `getAriaValueText` | `function` |  | The spoken value. Default: the formatted value. |

### ImageCropperRotateButton

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |
| `by` | `-90 \| 90` |  | −90 turns counterclockwise, 90 clockwise, in both text directions. |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### ImageCropperFlipButton

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `variant` | `"default" \| "outline"` |  | `default`: no rest fill. `outline`: the field surface with an edge. |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` |  | Height 24, 28, 32, or 36px. |
| `rounded` | `"default" \| "full"` |  |  |
| `axis` | `"x" \| "y"` |  | `x` flips left and right, `y` up and down. |

Also takes every prop of Base UI `Toggle`: https://base-ui.com/react/components/toggle

### ImageCropperReset

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### ImageCropperAspectGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `fullWidth` | `boolean` |  |  |
| `orientation` | `"horizontal" \| "vertical"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` |  |  |
| `presets` | `readonly string[]` | ASPECT_RATIO_PRESETS | The ratio texts after Free and Original. Default: `ASPECT_RATIO_PRESETS`. |

Also takes every prop of Base UI `RadioGroup`: https://base-ui.com/react/components/radio-group

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ImageCropper | `image-cropper` |  |  |  |
| ImageCropperViewport | `image-cropper-viewport` | `data-disabled`, `data-gesture` |  | `shimmer` |
| ImageCropperEmpty | `image-cropper-empty` |  |  |  |
| ImageCropperImage | `image-cropper-image` |  | `--image-cropper-flip-x`, `--image-cropper-flip-y`, `--image-cropper-rotation`, `--image-cropper-scale`, `--image-cropper-x`, `--image-cropper-y` |  |
| ImageCropperArea | `image-cropper-area` |  | `--image-cropper-crop-height`, `--image-cropper-crop-width`, `--image-cropper-crop-x`, `--image-cropper-crop-y`, `--radius`, `--ring` | `motion-timing` |
| ImageCropperGrid | `image-cropper-grid` | `data-interacting` |  | `motion-timing` |
| ImageCropperHandle | `image-cropper-handle` | `data-active` | `--radius` | `hit-area`, `motion-timing` |
| ImageCropperZoomSlider | `image-cropper-zoom-slider` |  |  | `hit-area` |
| ImageCropperRotateSlider | `image-cropper-rotate-slider` |  |  |  |
| ImageCropperRotateButton | `image-cropper-rotate-button` |  |  |  |
| ImageCropperFlipButton | `image-cropper-flip-button` |  |  |  |
| ImageCropperReset | `image-cropper-reset` |  |  |  |
| ImageCropperAspectGroup | `image-cropper-aspect-group` |  |  | `scroll-fade` |

## Usage

Give `ImageCropperViewport` a height. A host with no CORS header fails to load, so pass `crossOrigin={null}` if you only show the picture.

```tsx title="photo-crop.tsx"
import { ImageCropper, ImageCropperAspectGroup, ImageCropperViewport } from "@/components/pro/media/image-cropper";

export function PhotoCrop({ src }: { src: string }) {
  return (
    <ImageCropper src={src}>
      <ImageCropperViewport className="h-72" />
      <ImageCropperAspectGroup />
    </ImageCropper>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/image-cropper
```

It adds 67 registry items: 61 files, 12454 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Ruler Slider](https://gelatinui.com/components/ruler-slider.md)
- [Button](https://gelatinui.com/components/button.md)
- [Segmented Control](https://gelatinui.com/components/segmented-control.md)
- [Slider](https://gelatinui.com/components/slider.md)
- [Spinner](https://gelatinui.com/components/spinner.md)
- [Toggle](https://gelatinui.com/components/toggle.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Dropzone](https://gelatinui.com/components/dropzone.md)
- [Ruler Slider](https://gelatinui.com/components/ruler-slider.md)
- [Slider](https://gelatinui.com/components/slider.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Arrow keys | Crop box: moves the picture 1px. With Shift, it moves 10px. |
| Alt + arrow keys | Crop box: resizes the crop from its center. Right and Up grow it; Left and Down shrink it. This needs free handles. |
| +, - | Crop box: zooms by 0.1×. |
| [, ] | Crop box: turns the picture by 90°. |
| Arrow keys | Handle: moves the corner or edge 1px. With Shift, it moves 10px. |
| Home, End | Handle: moves the corner or edge to its minimum or maximum. |
| Arrow keys | `ImageCropperRotateSlider`: changes the turn by 0.1°. With Shift, it changes by 1°. |
| Delete | `ImageCropperRotateSlider`: resets the turn. |

## Accessibility

The crop area and each handle take focus. The arrow keys move or resize the crop.

Zoom and straighten are real sliders, and each control has a name from `labels`.

Translate the names with the `labels` prop, and keep that object stable.

## Motion

| Part | Motion |
| --- | --- |
| Press | press · 100ms · ease-out (0, 0, 0.2, 1) |
| Grid | fade · 150ms · ease-out (0, 0, 0.2, 1) · the grid shows during a change |
