terra vidhal

File Drop

Component

About

A drag-and-drop upload zone that breathes on drag, fills a spring progress bar, and draws its own check.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds File Drop to your project and fits it to your theme.

Code

How File Drop is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

/**
 * PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
 */

import * as React from "react";
import { RotateCcw } from "lucide-react";
import { FileDrop, type FileDropStatus } from "@/components/ui/file-drop";

export default function FileDropDemo() {
  const [status, setStatus] = React.useState<FileDropStatus>("idle");
  const [progress, setProgress] = React.useState(0);
  const [fileName, setFileName] = React.useState<string | undefined>();
  const [resetKey, setResetKey] = React.useState(0);

  React.useEffect(() => {
    if (status !== "uploading") return;
    const timer = window.setInterval(() => {
      setProgress((current) => Math.min(100, current + 6 + Math.random() * 14));
    }, 160);
    return () => window.clearInterval(timer);
  }, [status]);

  React.useEffect(() => {
    if (status === "uploading" && progress >= 100) {
      setStatus("done");
    }
  }, [progress, status]);

  const startUpload = (name: string) => {
    setFileName(name);
    setProgress(0);
    setStatus("uploading");
  };

  const reset = () => {
    setStatus("idle");
    setProgress(0);
    setFileName(undefined);
    setResetKey((key) => key + 1);
  };

  return (
    <div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-100 via-white to-slate-200 p-6 dark:from-black dark:via-slate-950 dark:to-slate-900">
      <div className="w-full max-w-md rounded-3xl border border-border bg-background/90 p-8 shadow-2xl shadow-slate-900/10 backdrop-blur dark:shadow-black/40">
        <div className="mb-6 flex flex-col gap-2">
          <p className="text-[11px] font-medium uppercase tracking-[0.35em] text-muted-foreground">
            PrequelUI Animate
          </p>
          <h1 className="text-2xl font-semibold tracking-tight text-foreground">
            File Drop
          </h1>
          <p className="text-sm leading-relaxed text-muted-foreground">
            Drag a file in, or click to browse. The zone breathes on drag and
            fills a spring-loaded progress bar.
          </p>
        </div>

        <div className="flex flex-col items-center gap-4">
          <FileDrop
            key={resetKey}
            title="Drop a file or browse"
            hint="SVG, PNG, JPG or PDF — max 10 MB"
            accept=".svg,.png,.jpg,.jpeg,.pdf"
            maxSize={10 * 1024 * 1024}
            status={status}
            fileName={fileName}
            progress={
              status === "uploading" || status === "done"
                ? progress
                : undefined
            }
            onFiles={(files) => {
              const file = files[0];
              if (file) startUpload(file.name);
            }}
          />

          <button
            id="file-drop-reset"
            data-slot="file-drop-reset"
            type="button"
            onClick={reset}
            className="inline-flex items-center gap-2 rounded-full border border-border bg-background px-4 py-2 text-xs font-medium text-muted-foreground transition hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
          >
            <RotateCcw className="size-3.5" />
            Reset demo
          </button>
        </div>
      </div>
    </div>
  );
}

Dependencies

More by terra vidhal

View all
  • Morphing Text

    Morphing Text

  • Image Zoom

    Image Zoom

  • Sliding Number

    Sliding Number

  • Liquid Button

    Liquid Button

  • Gravity Stars Background

    Gravity Stars Background

Explore more

Part of PrequelUI Animate — browse the full library on 21st.dev.