File Uploader

A comprehensive file upload component with drag & drop support, progress tracking, and file validation.

Installation

Install the File Uploader component using your preferred package manager.

npxshadcn@latest addfile-uploader

Usage

The File Uploader component provides a complete file upload interface with drag & drop, progress tracking, and validation. It handles file selection, validation, and preview generation.

Live Preview

Upload Files

Drag and drop files here or click to browse

Images
PDF

Max 3 files, up to 5 MB each

Discover Its Features

The File Uploader component is packed with powerful features designed to provide an exceptional user experience.

Drag & Drop Support

Users can drag and drop files directly onto the upload area for seamless file selection.

File Validation

Automatically validates file types, sizes, and counts with customizable restrictions.

Upload Progress

Real-time progress indicators show upload status with visual feedback for each file.

Image Previews

Automatically generates preview thumbnails for uploaded image files.

Multiple Files

Support for uploading multiple files simultaneously with individual progress tracking.

File Management

Easy file removal with automatic cleanup of preview URLs.

API Reference

PropTypeDefaultDescription
onFilesReady(files: File[]) => voidundefinedCallback function called when files are ready or changed
maxFilesnumber10Maximum number of files that can be uploaded
maxSizenumber10 * 1024 * 1024 (10MB)Maximum file size in bytes
acceptstring[]['image/*', 'application/pdf', 'text/*']Array of accepted file types (e.g., ["image/*", "application/pdf"])
classNamestringundefinedAdditional class names for styling

Advanced Usage

Explore different configurations and use cases for the File Uploader component.

Basic File Uploader

Simple file uploader with default settings supporting images, PDFs, and text files.

Live Preview

Upload Files

Drag and drop files here or click to browse

Images
PDF
Text files

Max 10 files, up to 10 MB each

Single Image Uploader

Restrict uploads to a single image file with a smaller size limit, perfect for profile pictures or avatars.

Live Preview

Upload Files

Drag and drop files here or click to browse

Images

Max 1 files, up to 2 MB each

Document Uploader

Accept only document files (PDF, DOC, DOCX) with larger size limits for business documents.

Live Preview

Upload Files

Drag and drop files here or click to browse

PDF
application/msword
application/vnd.openxmlformats-officedocument.wordprocessingml.document

Max 5 files, up to 15 MB each

Media Files Uploader

Upload various media types including images, videos, and audio files with appropriate size limits.

Live Preview

Upload Files

Drag and drop files here or click to browse

Images
Videos
Audio

Max 8 files, up to 50 MB each

Complete Upload Flow

Full implementation with server upload, progress tracking, and success/error handling.

Live Preview

Upload Files

Drag and drop files here or click to browse

Images
PDF
Text files

Max 3 files, up to 10 MB each

Custom Styled Uploader

Customize the appearance and behavior with specific styling and constraints.

Live Preview

Upload Files

Drag and drop files here or click to browse

image/jpeg
image/png
image/webp

Max 2 files, up to 3 MB each