Thinking UI

File Drop ZonePRO

Drag files onto a chat to attach them, with per-file progress that resolves into checks.

Code

1 file · 351 lines of TypeScriptPRO

File Drop Zone is part of Pro

Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.

Motion notes

  • On drag-over the dashed border tightens and starts to march, the zone eases in slightly and the icon lifts, with the arrow rising a little more than its tile, as if it's being picked up.
  • Rows open their own height on the layout spring, so the list grows without pushing content in jumps. Progress bars use the same spring to smooth out uneven upload updates.
  • A rejected file gives a short, decaying shake on its row. It's enough to catch your eye without feeling like an alarm, and the reason replaces the size in place.
  • With reduced motion, the border and fill still change color, but the lift, the marching dashes and the shake are dropped. Progress updates without a spring.

Usage

Example
const [files, setFiles] = useState<DropzoneFile[]>([]);

  <FileDropzone
    files={files}
    maxSize={25 * 1024 * 1024}
    onFiles={(accepted, rejected) => {
      setFiles((f) => [
        ...f,
        ...accepted.map((file) => ({ id: crypto.randomUUID(), name: file.name, size: file.size, progress: 0, status: "uploading" as const })),
        ...rejected.map((file) => ({ id: crypto.randomUUID(), name: file.name, size: file.size, status: "error" as const, error: "Over the 25 MB limit" })),
      ]);
      accepted.forEach(upload); // update progress and status as it goes
    }}
    onRemove={(id) => setFiles((f) => f.filter((x) => x.id !== id))}
  />

Props

PropTypeDefaultDescription
filesDropzoneFile[][]Rows to show: { id, name, size (bytes), progress?, status: "uploading" | "done" | "error", error? }. You own upload state.
onFiles(accepted: File[], rejected: File[]) => void—Called on drop or browse. Files over maxSize arrive in rejected.
onRemove(id: string) => void—Shows a remove button on each row.
maxSizenumber—Max bytes per file. Also used for the default hint.
acceptstring—Passed to the file input, e.g. "image/*,.pdf".
multiplebooleantrueAllow more than one file per drop.
disabledbooleanfalseIgnores drops and clicks.
draggingboolean—Forces the drag-over look, e.g. when a drag starts elsewhere on the page.
labelstring"Drop files to attach"Main line while idle.
hintstring—Secondary line. Defaults to the size limit.
classNamestring—Classes for the wrapper.