Components

File Upload

new

A dropzone with a file list, previews, upload progress and validation.

Drop files here or click to browse

Images or PDF, up to 5 MB, 4 files at most

Files stay on your device in this demo.

Installation

npx shadcn@latest add @blank/file-upload

Usage

import {
  FileUpload,
  FileUploadDropzone,
  FileUploadList,
} from "@/components/ui/file-upload"
<FileUpload multiple accept="image/*" maxSize={5 * 1024 * 1024}>
  <FileUploadDropzone>Drop images here</FileUploadDropzone>
  <FileUploadList />
</FileUpload>

For a single file in a form row, reach for Input File instead. File Upload is the larger surface: a dropzone, a list with previews, and upload state per file.

Files are checked against onFileValidate, accept, maxSize and maxFiles in that order; each rejected file reaches onFileReject with a sentence you can show in FieldError. The dropzone is a button — click, Enter or Space opens the picker — and also takes drops and pasted files. Keep other interactive elements out of it; put a FileUploadTrigger beside it instead.

Examples

Upload progress

onUpload receives the accepted files and three callbacks. Report progress and the item shows a bar; report an error and it turns red with the message.

or drop them here

API Reference

FileUpload

PropTypeDefault
value / defaultValueFile[][]
onValueChange(files: File[]) => void—
acceptstring—
maxSizenumber (bytes)—
maxFilesnumber—
multiplebooleanfalse
onFileValidate(file: File) => string | null | undefined—
onFileReject(file: File, message: string) => void—
onAccept(files: File[]) => void—
onUpload(files, { onProgress, onSuccess, onError }) => Promise<void> | void—
disabled / requiredbooleanfalse
namestring—

Parts

PartNotes
FileUploadDropzoneClick, keyboard, drop and paste target. data-dragging, data-invalid.
FileUploadTriggerOpens the picker; asChild for a Button.
FileUploadListRenders every file; pass (file) => ReactNode to compose items.
FileUploadItemOne file. data-status: idle, uploading, success, error.
FileUploadItemPreviewThumbnail for images, an icon by type otherwise.
FileUploadItemMetadataName, size, progress or error.
FileUploadItemProgressA Progress bar while uploading.
FileUploadItemDeleteRemoves the file.
FileUploadClearRemoves every file; hidden when the list is empty.