GitHub
Core
Glass
Brutal
Humanist

File Upload

A set of components including drop areas, previews, and progress indicators that handle file uploads.

File Upload Playground

File Upload Playground
Preview
Code
Upload Documents
PDF, PNG, or JPG up to 10 MB
Controls
Upload Button:
Sample Link:
Multiple:
Disabled:

File Upload Progress Playground

File Upload Progress Playground
Preview
Code
Project_Specification.pdf
0 B of 412 KB • 3 secs left
0%
Uploading...
Controls
Icon Style:
Simple
Expressive
Status:
Uploading
Uploaded
Failed
File Type:
PDF
Image
Doc
Data

Installation

You can add the file upload component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx tailwind-merge @phosphor-icons/react @react-aria/focus @react-aria/interactions @react-aria/progress
2

Copy and paste the following code into your project.

Loading source code...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { FileUploadArea, FileUploadProgress } from '@versaui/ui/components/FileUpload';

// Upload Drop Area
<FileUploadArea
  title="Upload your documents"
  description="PDF, PNG, or JPG up to 10 MB"
  onFilesSelected={(files) => console.log(files)}
/>

// Upload Progress Card
<FileUploadProgress
  fileName="document.pdf"
  fileSize={1048576}
  fileType="application/pdf"
  onComplete={() => console.log('Complete')}
  onCancel={() => console.log('Cancel')}
  onDelete={() => console.log('Delete')}
/>

File Upload Area

Drop Area Options

// Custom copy & restrictions
<FileUploadArea
  title="Upload contract"
  description="PDF files up to 5 MB"
  accept="application/pdf"
  uploadButtonText="Select PDF"
/>

// Multiple files
<FileUploadArea multiple onFilesSelected={(files) => console.log(files)} />

// Sample template link
<FileUploadArea
  showSampleLink
  sampleLinkText="Download Template"
  onSampleDownload={() => console.log('Download template')}
/>

// Disabled
<FileUploadArea disabled />

File Upload Progress

Statuses

Three upload statuses are supported — uploading, uploaded, and failed:

// Uploading (active progress bar)
<FileUploadProgress
  fileName="report.pdf"
  fileSize={412888}
  fileType="application/pdf"
  initialStatus="uploading"
/>

// Uploaded (completed)
<FileUploadProgress
  fileName="report.pdf"
  fileSize={412888}
  fileType="application/pdf"
  initialStatus="uploaded"
  onDelete={() => console.log('Delete')}
/>

// Failed (error message and retry)
<FileUploadProgress
  fileName="report.pdf"
  fileSize={412888}
  fileType="application/pdf"
  initialStatus="failed"
  errorMessage="Upload Failed"
  onRetry={() => console.log('Retry')}
/>

Icon Styles

Two visual styles for the file icon — simple (default) and expressive:

<FileUploadProgress iconStyle="simple" fileName="document.pdf" fileSize={512000} initialStatus="uploaded" />
<FileUploadProgress iconStyle="expressive" fileName="document.pdf" fileSize={512000} initialStatus="uploaded" />

Accessibility

  • Full keyboard support: press Enter or Space on the drop area or upload button to open the file selector
  • Progress updates and status changes announced to screen readers via aria-live
  • Visible high-contrast focus rings when navigated via keyboard
  • Clear semantic action buttons with accessible labels for cancel, retry, and delete

FileUploadArea Props

PropTypeDefaultDescription
titlestring'Drag and drop a file here'Heading text in the drop zone.
descriptionstring'File type must be PDF, PNG or JPG under 5 MB'Subtext describing accepted files.
uploadButtonTextstring'Upload Files'Upload button label.
showUploadButtonbooleantrueShow or hide the upload button.
showSampleLinkbooleantrueShow or hide the sample file download link.
sampleLinkTextstring'Download Sample File'Sample download link label.
acceptstring—Accepted MIME types or extensions.
multiplebooleanfalseAllow multiple file selection.
disabledbooleanfalseDisable the upload area.
widthnumber | string600Width of the upload area container.
onFilesSelected(files: FileList) => void—Callback when files are selected or dropped.
onSampleDownload() => void—Callback when the sample link is clicked.
classNamestring''Additional CSS class names.
styleReact.CSSProperties—Additional inline styles.

FileUploadProgress Props

PropTypeDefaultDescription
fileNamestring—Name of the file being uploaded.
fileSizenumber—File size in bytes.
fileTypestring—MIME type or format of the file.
iconStyle'simple' | 'expressive''simple'Visual style for the file icon.
initialStatus'uploading' | 'uploaded' | 'failed''uploading'Initial upload status.
errorMessagestring'Upload Failed'Error message displayed on failure.
uploadSpeednumber200000Simulated speed in bytes per second.
simulateProgressbooleantrueWhether to simulate progress automatically.
widthnumber | string600Width of the progress card.
onComplete() => void—Callback when upload completes.
onCancel() => void—Callback when cancel is clicked.
onDelete() => void—Callback when delete is clicked.
onRetry() => void—Callback to retry failed upload.
classNamestring''Additional CSS class names.
styleReact.CSSProperties—Additional inline styles.

On this page