CropModal API

API reference docs for theCropModalwidget. For examples and details on the usage of this widget, visit the widget demo page.

Props

PropsTypeDescriptionDefault
isOpenbooleanControls whether the modal is visible._
imageUrlstring | nullInitial image URL. In online mode, a remote image can be fetched; otherwise users upload locally._
modalWrapperTranslationsModalWrapperTranslationsLabels for modal actions and headers. All fields are required._
modalWrapperTranslations.titlestringModal header title text.
modalWrapperTranslations.subtitlestringModal header subtitle/description text.
modalWrapperTranslations.saveButtonLabelstringText for the save/apply button.
modalWrapperTranslations.cancelButtonLabelstringText for the cancel button.
modalWrapperTranslations.closeModalButtonLabelstringAccessibility label for the close button (screen readers).
cropAreaTranslations?CropAreaTranslationsThese labels populate accessible names and tooltips for controls, and optionally render an "Upload new image" action on non-responsive layouts._
cropAreaTranslations?.zoomInButtonLabel?stringOptional label for the zoom-in button. Keep short and descriptive for screen readers (e.g., "Zoom in").
cropAreaTranslations?.zoomOutButtonLabel?stringOptional label for the zoom-out button. Keep short and descriptive for screen readers (e.g., "Zoom out").
cropAreaTranslations?.uploadNewButtonLabel?stringOptional label for the action to upload a new image. Rendered in the CropArea only when not in a responsive breakpoint.
dropAreaTranslations?DropAreaTranslationsLabels for file drop area. All fields are required._
dropAreaTranslations?.uploadImageButtonLabelstringText for the upload new file button.
dropAreaTranslations?.bottomTextSuffix?stringOptional text displayed after the link. Completes the inline sentence, e.g., " to continue."
dropAreaTranslations?.bottomTextPrefix?stringOptional text displayed before the link. Useful for sentences like "Drag and drop an image or ". When omitted, nothing is rendered.
dropAreaTranslations?.bottomLinkText?stringOptional text for the helper link (e.g., "browse files"). The link is rendered only when bottomLinkUrl is also provided.
dropAreaTranslations?.bottomLinkUrl?stringOptional absolute URL opened in a new tab when the helper link is clicked.
errorTranslations?ErrorTranslationsError messages for different scenarios. All fields are optional with default values.{fileSizeExceedsLimitError: 'This image file is too big. Please upload another.', fileTypeMismatchError: 'The file type is not supported.', fileUploadError: 'An error occurred while uploading the file.', androidFileReadError: 'Image couldn’t be uploaded. Please try again.', fetchIncomingImageError: 'An error occurred while fetching the image.', localFileProcessingError: 'An error occurred while uploading the file.' }
errorTranslations?.fileSizeExceedsLimitError?stringError when file size exceeds limit.This image file is too big. Please upload another.
errorTranslations?.fileTypeMismatchError?stringError when file type is not allowed.The file type is not supported.
errorTranslations?.fileUploadError?stringGeneric processing error message.An error occurred while uploading the file.
errorTranslations?.androidFileReadError?stringError during upload process.Image couldn’t be uploaded. Please try again.
errorTranslations?.fetchIncomingImageError?stringNetwork-related error message.An error occurred while fetching the image.
errorTranslations?.localFileProcessingError?stringError when local file processing fails.An error occurred while processing the image.
cropViewBoxOptions?CropViewBoxOptionsCrop box configuration: width, aspectRatio, and roundingStyle. All fields are optional with default values.{ width: 200, aspectRatio: 1, roundingStyle: "none" }
cropViewBoxOptions?.width?numberWidth of the crop box in pixels.200
cropViewBoxOptions?.aspectRatio?numberAspect ratio of the crop box (width/height).1
cropViewBoxOptions?.roundingStyle?"none" | "rounded" | "circle"Visual style of the crop box corners.none
generalOptions?GeneralOptionsCanvas sizing and behavior configuration. All fields are optional with default values.{ canvasWidth: 500, canvasHeight: 300, maxScaleFactor: 5, totalSidePadding: 48, saveButtonVariant: "accentPrimary" }
generalOptions?.canvasWidth?numberWidth of the canvas in pixels.500
generalOptions?.canvasHeight?numberHeight of the canvas in pixels.300
generalOptions?.maxScaleFactor?numberMaximum zoom scale factor for the image.5
generalOptions?.totalSidePadding?numberTotal padding on sides of the canvas in pixels.48
generalOptions?.saveButtonVariant?stringVisual variant for the save button.accentPrimary
imageProcessingOptions?ImageProcessingOptionsLocal file validation and optimization configuration. All fields are optional with default values.{ maxWidth: 2560, maxHeight: 2560, enableResize: true, maxFileSizeMB: 5, enableCompression: true, compressionQuality: 0.6, allowedMimeTypes: ["image/png", "image/jpeg", "image/jpg"] }
imageProcessingOptions.maxWidth?numberMaximum width for processed images in pixels.2560
imageProcessingOptions.maxHeight?numberMaximum height for processed images in pixels.2560
imageProcessingOptions.enableResize?booleanWhether to enable automatic image resizing.true
imageProcessingOptions.maxFileSizeMB?numberMaximum allowed file size in megabytes.5
imageProcessingOptions.enableCompression?booleanWhether to enable image compression.true
imageProcessingOptions.compressionQuality?numberCompression quality (0-1, where 1 is highest quality).0.6
imageProcessingOptions.allowedMimeTypes?string[]Array of allowed MIME types for uploaded files.["image/png", "image/jpeg", "image/jpg"]
apiOptions?ApiOptions | undefinedEnable online mode: provide uploadUrl, getAccessToken, and helpers to fetch/upload images. When omitted, the widget operates in offline mode using blob URLs only.
apiOptions?.uploadUrlstringURL endpoint for uploading processed images.
apiOptions?.getAccessToken() => Promise<string>Function that returns an access token for API authentication.
apiOptions?.sendFormDataRequest?(url: string, file: File, formParams: Record<string, string>) => Promise<string>Function to send form data (e.g., image file) to server and return image URL.
apiOptions?.fetchInitialImageUrl?(url: string) => Promise<Blob>;Function to fetch initial image URL from server.
apiOptions?.fetchGoogleStorageUploadUrl?(accessToken: string, fileName: string) => Promise<GoogleStorageApiResponse>Function to fetch Google Storage upload URL from server.
onSuccessfulUpload(url: string, imageData?: ImageData) => voidCalled after a successful image upload and client-side processing._
onClose() => voidCalled when the modal is closed via close button, overlay click, or pressing Esc (when enabled)._
onCancel() => voidCalled when the user clicks the Cancel action in the modal._
onError?(error: ErrorDetails) => voidOptional error callback for recoverable failures in the workflow._