Skip to main content

File Upload Dropzone

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The FileUploadDropzone component provides a complete file upload solution with drag & drop functionality, file previews, progress tracking, and validation. Built with react-dropzone, it offers an intuitive interface for handling single or multiple file uploads with comprehensive error handling and customization options.

Basic Usage​

With Custom Configuration​

Single File Upload​

With Upload Progress​

Document Upload Form​

Document Upload
Photo Gallery

Disabled State​

File upload is temporarily unavailable. Please try again later.

Properties​

FileUploadDropzone​

PropertyTypeDescription
configFileUploadConfigConfiguration object for upload behavior.
onFilesChange(files: UploadedFile[]) => voidCallback fired when file list changes.
onFileUpload(file: UploadedFile) => Promise<void>Function to handle individual file upload.
classNamestringAdditional CSS classes for the container.
placeholderstringText displayed in the drop zone.

FileUploadConfig​

PropertyTypeDefaultDescription
maxFilesnumber5Maximum number of files allowed.
maxSizenumber10MBMaximum file size in bytes.
acceptedFileTypesstring[]['image/*', 'application/pdf', '.doc', '.docx']Accepted file types/extensions.
multiplebooleantrueWhether multiple files are allowed.
disabledbooleanfalseWhether the upload is disabled.
showPreviewbooleantrueWhether to show image previews.
showProgressbooleantrueWhether to show upload progress bars.

UploadedFile​

PropertyTypeDescription
idstringUnique identifier for the file.
namestringOriginal filename.
sizenumberFile size in bytes.
typestringMIME type of the file.
previewstringPreview URL for images (optional).
progressnumberUpload progress percentage (0-100).
errorstringError message if upload failed (optional).

File Type Examples​

Common MIME Types​

  • Images: image/*, image/jpeg, image/png, image/gif, image/webp
  • Documents: application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • Text: text/plain, text/csv
  • Archives: application/zip, application/x-rar-compressed

File Extensions​

  • Images: .jpg, .jpeg, .png, .gif, .webp, .svg
  • Documents: .pdf, .doc, .docx, .txt, .rtf
  • Spreadsheets: .xls, .xlsx, .csv
  • Presentations: .ppt, .pptx

Accessibility​

The FileUploadDropzone component includes comprehensive accessibility features:

  • Keyboard Navigation - Full keyboard support for file selection
  • Screen Reader Support - Proper ARIA labels and file status announcements
  • Focus Management - Clear focus indicators and logical tab order
  • Drag and Drop - Accessible drag and drop with keyboard alternatives
  • Error Handling - Clear error messages for validation failures
  • Progress Indicators - Accessible progress bars and status updates

Common Use Cases​

The FileUploadDropzone component is perfect for:

  • Profile Pictures - Single image upload with preview
  • Document Management - Multiple document upload with validation
  • Media Galleries - Batch image upload for galleries
  • Form Attachments - File attachments in contact or support forms
  • Content Management - Article images and media uploads
  • Data Import - CSV and Excel file uploads
  • Backup Uploads - Archive and backup file handling

Best Practices​

  1. File Validation - Always validate file types and sizes on both client and server
  2. Progress Feedback - Show upload progress for better user experience
  3. Error Handling - Provide clear, actionable error messages
  4. Preview Images - Show thumbnails for image files when possible
  5. Size Limits - Set reasonable file size limits based on your use case
  6. Security - Scan uploaded files for malware and validate content
  7. Storage Management - Implement proper file storage and cleanup
  8. Mobile Support - Ensure the component works well on touch devices