Skip to main content

FileDrop

import { FileDrop } from "@study/ui"

Result
Loading...
Live Editor
function Example() {
  const [names, setNames] = useState([]);
  return (
    <div className="ui-stack">
      <FileDrop label="Upload files" hint="Drag here or click · PDF, Word, images · up to 95 MB" accept=".pdf,.docx,image/*" onFiles={(files) => setNames(files.map((f) => f.name))} />
      {names.length > 0 && <p>Chosen: {names.join(", ")}</p>}
    </div>
  );
}

Variants and states​

Light

Dark

When to use​

  • Where uploading is the task: the Documents tab, an empty folder.
  • Otherwise an "Upload" Button with the icon upload that opens a file dialog is enough.
  • The hint names kind and size – nobody should learn about the 95 MB limit per file only from an error.

Props​

PropTypeDefaultMeaning
label *ReactNode–What to do here, e.g. "Upload files".
onFiles *(files: File[]) => void–
acceptstring–As for `<input type=file>`, e.g. ".pdf,.docx,image/*".
classNamestring–
disabledboolean–
hintReactNode–Which files and how large, e.g. "PDF, Word, images · up to 95 MB".
multiplebooleantrue

Accessibility​

  • Underneath is a real <input type="file">: reachable with Tab, Enter opens the dialog.
  • Drag and drop is an extra, never the only way.