RE

React Dropzone

react-dropzone

Simple HTML5 drag-drop zone with React.js

Component Libraries
drag
drop
react
react-component
upload
react-dropzone
Component Libraries
javascript
npm
frontend
Stars
11k
Weekly
12M
Open issues
3
Bundle
~15 kB

Installation

npm install react-dropzone

Code example

import { useDropzone } from "react-dropzone";

export function Example() {
  const { getRootProps, getInputProps, isDragActive } = useDropzone({
    onDrop: (files) => console.log(files),
  });

  return (
    <div {...getRootProps()}>
      <input {...getInputProps()} />
      <p>{isDragActive ? "Drop files here" : "Drag files or click to browse"}</p>
    </div>
  );
}

Pros & cons

Pros

  • Actively maintained by Param Aggarwal
  • 12M weekly downloads. Battle tested
  • First-class TypeScript definitions
  • MIT licensed

Considerations

  • Adds roughly ~15 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 3 open issues on GitHub

FAQs

Alternatives & similar libraries