File Upload Component
A comprehensive file upload component with drag and drop functionality, image compression, and advanced features.
Basic Example
A simple file upload component with default styling.
Drag & Drop files here
or click to browse files from your computer
Image Upload with Compression
A responsive image gallery component with advanced features.
Upload Images
Accepts JPG, PNG, GIF up to 10MB (max 5 files)
Images will be automatically compressed
Document Upload
An example of a document upload component.
Upload Document
Accepts PDF, DOC, DOCX, TXT files up to 20MB
API Reference
FileUpload
The main container component that provides context for all file upload components. It manages the file state, validation, and provides all necessary context to child components.
FileUploadDropzone
A container that handles drag and drop functionality. It provides visual feedback during drag operations and automatically handles file drops.
FileUploadTrigger
A button component that triggers the file selection dialog. It automatically handles the hidden file input and can be customized with any button props.
FileUploadInput
The actual HTML file input element. Usually hidden and triggered by FileUploadTrigger. Handles the file selection and validation.
FileUploadList
Displays the list of selected files with Next.js Image optimization for previews. Supports both list and grid views with sorting and filtering capabilities.
FileUploadItem
Individual file item component with Next.js Image preview, file information, and remove functionality. Automatically handles image previews and file type icons.
FileUploadProgress
Displays upload progress with a progress bar and percentage. Shows additional information like chunk size and upload status.
FileUploadError
Displays validation errors and upload errors in a dismissible format. Shows file-specific errors with detailed error messages.
FileUploadToolbar
Advanced toolbar with view toggle (list/grid), sorting options, file type filtering, and image compression controls. All features can be individually enabled or disabled.
FileUploadGallery
Grid view for image files with Next.js Image optimization. Shows image previews in a responsive grid with hover effects and remove functionality.
useFileUpload Hook
Custom hook to access the file upload context. Provides all state and methods for managing files, validation, and UI state.
Complete Example
A comprehensive example showing all components working together with custom validation and upload handling.
Key Features
Core Features
- Drag and drop file upload
- Multiple file selection
- File type validation
- File size limits
- Custom validation functions
- Progress tracking
- Error handling and display
- File preview with Next.js Image
Advanced Features
- Image compression with quality control
- Grid and list view modes
- File sorting (name, size, type, date)
- File type filtering
- Chunked upload support
- Full TypeScript support
- Accessibility compliant
- Mobile responsive design
Browser Support
The file upload component supports all modern browsers with the following features:
Drag and Drop
- Chrome 4+
- Firefox 3.5+
- Safari 6+
- Edge 12+
File API
- Chrome 13+
- Firefox 7+
- Safari 6+
- Edge 12+