Skip to main content

API

ImageUploadProps

NameDescriptionTypeDefault
childrencustom upload zoneReact.ReactNode
widthimage widthnumber100
heightimage heightnumberwidth
valuedefault imagesValueType
onChangecallback for when the images changes(value: ValueType) => void
transformtransform images to value(images: ImageItem[], max: number) => ValueTypedefaultTransform
onUploadcallback for when the drop event occurs(file: File) => string | Promise<string>defaultUpload
maxmax image numbernumberInfinity
readonlyfor previewboolean
classNameroot classNamestring
itemClassNameimage classNamestring
dropzoneClassNamedropzone classNamestring
dropzoneOptionsDropzoneOptions
photoProviderPropsOmit<PhotoProviderProps, "children">

Types & Defaults

type ValueItem = {
url: string;
name?: string;
};

type ValueType = string | ValueItem | (string | ValueItem)[];

type ImageItem = {
id?: string;
url?: string;
name?: string;
file?: File;
loading?: boolean;
};

const defaultUpload = (file: File) => URL.createObjectURL(file);

const defaultTransform = (images: ImageItem[], max: number): ValueType => {
const value = images.map((item) => item.url);
if (max === 1) {
return value.join(",");
}
return value;
};