Description
react-dropzone is a simple React hook and wrapper component for building an HTML5 drag-and-drop zone that accepts files. You can use the useDropzone hook to get the props for the zone, or the Dropzone wrapper component, which exposes an open method you can call to open the file dialog. The root props from getRootProps can be applied to any element, and the input props from getInputProps must be applied to an input element, otherwise opening the file dialog will not work. The README warns to pass your own props through getRootProps rather than setting them directly, so they are not overridden. To read file contents, you use the browser's FileReader API on the files it gives you. The package is installed from npm, ships as ESM and CommonJS with TypeScript types, and works with bundlers such as Vite, webpack and Rspack. Its refKey option lets you attach the ref to elements that do not forward a reference. The README also explains how to test components that use it with react-testing-library, since some drag callbacks are asynchronous.…
Highlights
- React hook and Dropzone wrapper component
- Installs from npm with TypeScript types
- Works with Vite, webpack and Rspack
- Props getters and a refKey option
- Guidance for testing with react-testing-library
Ratings & Reviews
No ratings yet
Be the first to rate react-dropzone.
People also visit
react-dropzone FAQ
What does react-dropzone do?
It creates a drag-and-drop zone in a React app that accepts files, using the HTML5 drag-and-drop events.
How do I install it?
Install react-dropzone from npm. It ships with TypeScript types and works with modern bundlers.
How do I open the file dialog?
Bind the props from getInputProps to an input element, or use the Dropzone component's open method. Without the input, opening the dialog will not work.
How do I read the file contents?
Use the FileReader API on the files the dropzone returns, as shown in the README.
How do I test components that use it?
The README recommends react-testing-library, because some drag callbacks are asynchronous.
Where is the documentation?
At react-dropzone.js.org, with the source on GitHub.
What are the best react-dropzone alternatives?
Popular alternatives to react-dropzone include react-mui-dropzone, @files-ui/react and react-magic-dropzone. See all react-dropzone alternatives



















