API Reference

react-dropzone

React hook for accessible drag-and-drop file selection with accept filters, size limits, multiple files, and keyboard-accessible input fallback.

Official Documentation ↗
CompatibilityThis documentation covers version react-dropzone 14.x with React 18/19; accept uses MIME types and extensions. Check the official docs for the latest API surface.

Installation

npmnpm install react-dropzone
pnpmpnpm add react-dropzone
yarnyarn add react-dropzone

Methods

react-dropzone provides a hook for drag-and-drop file selection without giving up the native file input. The hook returns props for a drop zone and an input, plus accepted files, rejections, and drag state.

Keep the input

The native input is the accessible path. Spread getInputProps() onto it and provide a label. A div-only drop target that listens for clicks is not keyboard accessible and often blocks assistive technology. Show rejection messages with role="alert" or an aria-live region.

Upload separately

The library does not perform uploads. Send accepted files with FormData, track progress and cancellation, and handle server errors. Treat the client filters as convenience; the server must repeat validation and enforce storage, authentication, and malware policies.

FAQ

Does react-dropzone upload files for me?
No. It handles selection and drag-and-drop state. You still send the files with fetch or XMLHttpRequest and show progress, errors, and cancellation.
Are accept and maxSize security controls?
No. They improve the picker experience but can be bypassed. Validate the file signature and enforce size limits on the server.
How do I make the drop zone keyboard accessible?
Keep the input from getInputProps, associate a label or aria-label, and ensure Enter or Space on the drop zone opens the picker. Test with a keyboard and a screen reader.