Select file or drag here
Select file or drag here
Attach up to 2 files.Button
Use the children node to overwrite the default dropzone interface. Allow for a custom interface.
Disabled
Select file or drag here
Bind to API
You can optionally bind to the internal Zag component API to access additional methods such as clearFiles().
Select file or drag here
RTL
Select file or drag here
Additional Features
Accepted File Formats
<FileUpload accept="image/*"><FileUpload accept={"text/html": [".html", ".htm"]}>File Validation
<FileUpload maxFiles={5}><FileUpload minFileSize={1024 * 1024 * 5}> {/* 5 mb */}<FileUpload maxFileSize={1024 * 1024 * 10}> {/* 10 mb */}Custom Validation
function validateFileSize(file) { if (file.size > 1024 * 1024 * 10) return ["FILE_TOO_LARGE"]; return null;}<FileUpload validate={validateFileSize} onFileReject={console.error}>Events
<FileUpload onFileChange={console.log}> {/* Triggers when files changed. */}<FileUpload onFileAccept={console.log}> {/* Triggers when files are accepted. */}<FileUpload onFileReject={console.error}> {/* Triggers when files are rejected. */}Image Previews
function generatePreview(event) { const reader = new FileReader(); reader.onload = (event) => { const image = event.target.result; // set the image as the src of an image element } reader.readAsDataURL(details.acceptedFiles[0]);}<FileUpload onFileChange={generatePreview}>Miscellaneous
<FileUpload allowDrop> {/* Enable drag-and-drop */}<FileUpload directory> {/* Enable dirctories */}<FileUpload capture> {/* Enable media capture on mobile devices */}API Reference
FileUpload
| Property | Type | Description |
|---|---|---|
label | string | |
subtext | string | |
base | string | |
classes | string | |
interfaceBase | string | |
interfaceBg | string | |
interfaceBorder | string | |
interfaceBorderColor | string | |
interfacePadding | string | |
interfaceRounded | string | |
interfaceClasses | string | |
interfaceIcon | string | |
interfaceText | string | |
interfaceSubtext | string | |
filesListBase | string | |
filesListClasses | string | |
fileBase | string | |
fileBg | string | |
fileGap | string | |
filePadding | string | |
fileRounded | string | |
fileClasses | string | |
fileIcon | string | |
fileName | string | |
fileSize | string | |
fileButton | string | |
stateDisabled | string | |
stateInvalid | string | |
stateDragging | string | |
iconInterface | React.ReactNode | |
iconFile | React.ReactNode | |
iconFileRemove | React.ReactNode | |
children | React.ReactNode | |
required | boolean | |
name | string | |
dir | string | |
directory | boolean | |
getRootNode | object | |
disabled | boolean | |
accept | (unknown) | |
capture | string | |
locale | string | |
ids | Partial<...> | |
translations | IntlTranslations | |
allowDrop | boolean | |
maxFileSize | number | |
minFileSize | number | |
maxFiles | number | |
validate | object | |
onFileChange | object | |
onFileAccept | object | |
onFileReject | object | |