Image cropper (UI SDK): Controller
onCropCommit runs once a drag or key press ends, so save there. A controller from createImageCropperController() sets the crop from anywhere.
Move the crop to save it.
This adds the example as components/examples/ui-sdk-image-cropper/controlled.tsx, together with the Image cropper component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-image-cropper-controlled.jsonTo add only the component, follow the Image cropper installation.
Props in this example
The Image cropper props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
src | string | – |
defaultCrop | ImageCrop | – |
onCropCommitRuns once a drag, key press or wheel ends. | (crop, details) => void | – |
aspectRatio | number | – |
controllerFrom createImageCropperController(). | ImageCropperController | – |
| Prop | Type | Default |
|---|---|---|
altRequired. | string | – |
Every prop is in the Image cropper API reference.
See them all, with keyboard support and accessibility notes, on the Image cropper page.