Skip to main content

File Upload

An interface that allows users to select and upload files from their device, with visual feedback on upload status and file validation.

import { FileUpload } from "@/components/ui/file-upload"

function FileUploadExample() {
return (
<FileUpload
label="File Uploader"
maxFiles={2}
maxSizeMB={5}
accept="image/*"
onChange={(files) => console.log(files)}
/>
)
}

API Reference

PropTypeDefaultDescription
labelstring"File Uploader"Label text displayed above the drop zone
maxFilesnumber2Maximum number of files allowed
maxSizeMBnumber5Maximum file size in megabytes
acceptstringAccepted file types (e.g. "image/*", ".pdf,.doc")
onChange(files: File[]) => voidCallback when files are added or removed
classNamestringAdditional CSS classes

Accessibility

The File Upload component is built with accessibility in mind:

  • The drop zone is keyboard accessible via Enter and Space keys
  • Each action button (edit, download, delete) has a descriptive aria-label
  • The drop zone has an aria-label describing file constraints
  • Uses role="button" with tabIndex={0} for the drop zone
  • Visual drag state feedback uses border and background changes, not color alone