Skip to content

File Upload

Used to select files to be uploaded from the user’s device.

import { useState } from 'react';
import { FileUpload } from '@fintech-sandpit/ui/react';
const [files, setFiles] = useState<File[]>([]);
return (
<FileUpload
value={files}
accept=".jpg,.png"
maxFileSize={256 * 1024}
dropZoneLabel={(
<div className="text-center text-sm">
<p>
Click to upload, or drag and drop your file here.
</p>
<p className="space-x-2">
<span>
Accepted:
</span>
<strong>
JPG, PNG &ndash; Max 256 KB
</strong>
</p>
</div>
) : undefined}
onChange={setFiles}
onReject={(file, errors) => {
alert(errors[0]);
}}
/>
);
NameTypeDefaultDescription
valueFile[]The list of files to be uploaded
labelstringThe label of the file upload
namestringThe name of the file upload
acceptstring | string[]The accepted file types
dropZonebooleanWhether to use a drop zone
dropZoneInnerReactNodeThe content of the drop zone
dropZoneLabelReactNodeThe content of the drop zone label
multiplebooleanWhether to allow multiple files
maxFilesnumberThe maximum number of files to upload
minFileSizenumberThe minimum file size
maxFileSizenumberThe maximum file size
uploadTriggerReactNodeThe content of the upload trigger
directorybooleanWhether to allow directory uploads
disabledbooleanWhether the file upload is disabled
NameDescription
drop-zone-innerThe content of the drop zone
drop-zone-labelThe content of the drop zone label
upload-triggerThe content of the upload trigger
NameTypeDescription
onChange(files: File[]) => voidCallback fired when the files are added or removed
onAccept(file: File) => voidCallback fired when the file is accepted
onReject(file: File, errors: FileError[]) => voidCallback fired when the file is rejected