FileDrop

Wakes as a file nears, swallows it, shows the upload on a ring and floods green. Inputs.

Open playground
Drop your file here
Drop a file here or click to browse

About

FileDrop is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { FileDrop } from "@ashutoshswamy/smoui" and set onFile, accept, maxSize among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { FileDrop } from "@ashutoshswamy/smoui";

<FileDrop
  accept="image/*,.pdf"
  maxSize={20e6}
  onFile={async (file, onProgress) => {
    await upload(file, onProgress); // fraction 0 to 1
  }}
/>

Props 4

onFile

Receives the file. Return a promise to drive the ring; without onFile progress is simulated and nothing is sent.

(file: File, onProgress: (f: number) => void) => Promise<void> | void
accept

Allowed types, like the input accept attribute.

string
maxSize

Largest file in bytes.

number
hint

Idle helper line.

stringdefault "Drop a file here or click to browse"