File Upload
A dropzone that leans in when you drag, with image previews, per-file progress, retry and validation.
Inputs
Drop files here or click to browse
PNG, JPG or PDF up to 5.0 MB
Playground
Tweak the props, the preview and the code follow.
Drop files here or click to browse
Props
5
<FileUpload
maxFiles={5}
onUpload={async (file, progress) => {
await upload(file, progress)
}}
/>Installation
npx @plumsydev/plum-ui add file-uploadUsage
import { FileUpload } from "@/components/ui/file-upload"<FileUpload
accept="image/*"
maxSize={5 * 1024 * 1024}
onUpload={async (file, progress) => {
// send the file, call progress(0..100) along the way
}}
/>Examples
Single file
Company logo
Upload a logo
SVG or PNG, square works best
Errors & retry
Reject the promise returned by onUpload to show the error state.
Drop anything
About a third of uploads fail on purpose. Hit retry.
API Reference
FileUpload
| Prop | Type | Default |
|---|---|---|
onUploadDoes the upload. Defaults to a simulation for demos. | (file: File, progress: (pct: number) => void) => Promise<void> | — |
acceptSame syntax as the HTML attribute. | string | — |
maxSizeMax bytes per file. | number | — |
maxFilesMax files in the list. | number | Infinity |
multipleAllow picking several files. | boolean | true |
onFilesChangeCalled when the set of finished uploads changes. | (files: File[]) => void | — |
onRejectCalled for files that fail validation. | (file: File, reason: string) => void | — |
title / descriptionDropzone copy. | ReactNode | — |
Notes
- The dropzone is focusable and opens the file dialog with Enter or Space.