File Upload

A fully reusable, premium file upload component with drag-and-drop, validation, and real-time upload progress previews.

formclass-variance-authorityframer-motionlucide-react

Installation

$npx futureuikit add file-upload

Import

import { FileUpload } from "@/components/ui/file-upload"
Layout Variant
Color Theme

Named Keys & Props

Pass these exact named keys as props on <FileUpload />. Click any color pill to copy the prop.

colorDefault is "default"(Black & White)
variantVisual style
"solid""outline""ghost""link"
themeSurface theme
"default""modern""clean""futuristic""brutal""halftone"
shapeCorner shape
"default""square""rounded""sharp"
spacingInner spacing
"default""2x""4x""6x""8x"
sizeComponent size
"default""sm""md""lg""xl""full"

Usage Example

A basic implementation example to get you started.

Example Implementation
import { FileUpload, UploadDropzone, UploadPreview, UploadProgress } from "@/components/ui/file-upload";

export default function Example() {
  return (
    <FileUpload
      variant="solid"
      theme="modern"
      color="default"
      maxFiles={3}
      maxSize={5 * 1024 * 1024} // 5MB
      accept={{
        "image/*": [".png", ".jpg", ".jpeg"],
      }}
      onUpload={(files) => console.log("Uploading:", files)}
    >
      <UploadDropzone title="Drag images here" />
      <UploadPreview />
      <UploadProgress />
    </FileUpload>
  );
}

Features

Key capabilities and highlights.

Key Capabilities
  • ◆Built natively using standard HTML5 drag-and-drop events.
  • ◆Generates rich thumbnails for images and videos automatically.
  • ◆Compound component architecture (FileUpload, Dropzone, Preview, Progress).
  • ◆Handles validation rules like max files, size limits, and MIME type restrictions.
  • ◆Smooth, physics-based state transitions powered by Framer Motion.

Notes

Important implementation details to consider.

Implementation Details
  • ◆Overview: A powerful compound File Upload component allowing users to drag and drop or browse for files.
  • ◆Installation: Run'npx futureuikit add file-upload'to add it to your project.
  • ◆Validation: Pass'maxSize'(in bytes),'maxFiles', and an'accept'map to restrict uploads.
  • ◆Handling Uploads: Provide an'onUpload'callback which fires automatically with a list of valid files ready for submission.
  • ◆Variants & Themes: Pass 'variant' ('solid', 'outline', 'ghost', 'link'), 'theme' ('default', 'modern', 'clean', 'futuristic', 'brutal', 'halftone'), and any of the 10 named 'color' keys.
  • ◆Progress: In a real app, update the internal progress state via the'onFilesChange'hook to visualize upload metrics.