A versatile component for handling file uploads with drag and drop support.
Import the FileUpload
component and its subcomponents from @bun-ui/react
:
import { FileUpload, FileUploadDropZone, FileUploadTrigger, FileUploadList } from "@bun-ui/react"
The FileUpload component provides two ways to trigger file selection:
FileUploadDropZone
for drag and drop functionality:<FileUpload>
<FileUploadDropZone>
<p>Drag and drop files here, or click to select files</p>
</FileUploadDropZone>
<FileUploadList/>
</FileUpload>
FileUploadTrigger
for a simple button trigger:<FileUpload>
<FileUploadTrigger>Select Files</FileUploadTrigger>
<FileUploadList/>
</FileUpload>
A simple file upload with drag and drop support.
Drag and drop files here, or click to select files
Upload multiple files at once.
Drag and drop multiple files here, or click to select files
Restrict file types using the accept
prop.
Drag and drop images here, or click to select images
Limit the number of files that can be uploaded.
Drag and drop images here
.jpg, .jpeg, .png up to 5 files
Disable the file upload component.
File upload is currently disabled
Use prop asChild
in FileUploadTrigger
to create a custom trigger element.
Use the FileUpload component within a form without any controlled state.
Use the FileUpload component with external state management and upload progress.
Drag and drop files here, or click to select files
You can preview the selected files before uploading them by using FileUploadPreviewList
component