Gathering detailed insights and metrics for react-file-drop
Gathering detailed insights and metrics for react-file-drop
Gathering detailed insights and metrics for react-file-drop
Gathering detailed insights and metrics for react-file-drop
react-drag-drop-files
Light React Drag & Drop files and images library styled by styled-components
react-butterfiles
A component for building file upload fields of any type.
@rpldy/upload-drop-zone
drop zone (container) component to initiate file and folder content uploads
react-filepond
A handy FilePond adapter component for React
React component for Gmail or Facebook -like drag and drop file uploader
npm install react-file-drop
Typescript
Module System
Node Version
NPM Version
96.7
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
TypeScript (87.91%)
JavaScript (12.09%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
176 Stars
202 Commits
54 Forks
5 Watchers
4 Branches
21 Contributors
Updated on Jun 05, 2025
Minified
Minified + Gzipped
Latest Version
3.1.6
Package Id
react-file-drop@3.1.6
Unpacked Size
20.29 kB
Size
5.88 kB
File Count
6
NPM Version
6.13.4
Node Version
13.5.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Zero dependency React component for Gmail or Facebook -like drag and drop file uploader. Drag files anywhere onto the window (or user defined 'frame' prop)! Very extensible, provides a hook for every event so you can use it to develop any custom behavior that you want.
https://sarink.github.io/react-file-drop - A very simple live demo with example code and sample CSS
I wanted that behavior that facebook, gmail, etc. have where a part of the page highlights immediately when you start dragging a file anywhere on the window. I couldn't find any React component that already did this, so, I made one!
None! (well, just prop-types
, but that should already be removed from your prod bundle anyway)
✅ Chrome
✅ Firefox
✅ Safari
✅ IE 11
✅ IE Edge
npm install --save react-file-drop
import { FileDrop } from 'react-file-drop'
First, you define the frame
prop (default is the document
), whenever the user begins dragging file(s) anywhere over this frame, the target
will get a file-drop-dragging-over-frame
class name, and the onFrameDragEnter
callback will fire.
Next, define an onDrop
prop, whenever a user drops their files onto the target
, this callback will be triggered.
Lastly, you'll need to style it.
You can also define an onTargetClick
prop if you want to let user browse their files from disk. Below you can find instruction how to do that.
By default, the component comes with no styles. You can grab the demo CSS to get started.
For custom class names (if you're using something like JSS) you can use the following props:
className
targetClassName
draggingOverFrameClassName
draggingOverTargetClassName
.file-drop
: The outer container element
.file-drop > .file-drop-target
: This is the target the user has to drag their files to.
.file-drop > .file-drop-target.file-drop-dragging-over-frame
: This class will be added to the target
whenever the user begins dragging a file over the frame
, and it will be removed when they leave
.file-drop > .file-drop-target.file-drop-dragging-over-target
: This class will be added to the target
whenever the user begins dragging a file over the target
, and it will be removed when they leave
onDrop: function(files, event)
: Callback when the user drops files onto the target
onDragOver: function(event)
: Callback when the user is dragging over the target. Also adds the file-drop-dragging-over-target
class to the file-drop-target
.
onDragLeave: function(event)
: Callback when the user leaves the target. Removes the file-drop-dragging-over-target
class from the file-drop-target
.
onTargetClick: function(event)
: Callback when the user clicks anywhere on the target.
dropEffect - string "copy" || "move" || "link" || "none" (default: "copy")
: Learn more about HTML5 dropEffects. Not available in IE :(
frame: document || HTMLElement (default: document)
: This is the scope or "frame" that the user must drag some file(s) over to kick things off.
onFrameDragEnter: function(event)
: Callback when the user begins dragging over the frame
.
onFrameDragLeave: function(event)
: Callback when the user stops dragging over the frame
.
onFrameDrop: function(event)
: Callback when the user drops files anywhere over the frame
.
className: string (default: "file-drop")
: Class given to the outer container div.
targetClassName: string (default: "file-drop-target")
: Class given to the target div.
draggingOverFrameClassName: string (default: "file-drop-dragging-over-frame")
: Class given to the target div when file is being dragged over frame.
draggingOverTargetClassName: string (default: "file-drop-dragging-over-target")
: Class given to the target div when file is being dragged over target.
In order to let user upload files with click on the file-drop-target
, you will need to specify an input[type="file"]
somewhere in your code. You will also need a ref, that will be passed to the input, to call a click
method on it.
Steps:
1const fileInputRef = useRef(null);
1const onFileInputChange = (event) => { 2 const { files } = event.target; 3 // do something with your files... 4}
1<input 2 onChange={onFileInputChange} 3 ref={fileInputRef} 4 type="file" 5 className="hidden" 6/>
1const onTargetClick = () => { 2 fileInputRef.current.click() 3}
FileDrop
component:1<FileDrop 2 onTargetClick={onTargetClick}
Your PRs are welcome! To run the app locally:
nvm use # Probably optional, but it can't hurt
cd file-drop
npm install
npm start
cd demo
npm install
npm start
Now both the apps are running in watch mode. If you make a change to the file-drop code, you should see the demo code automatically rebuild and update in your browser.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 7/18 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
90 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More