Gathering detailed insights and metrics for @loopmode/react-file-drop
Gathering detailed insights and metrics for @loopmode/react-file-drop
Gathering detailed insights and metrics for @loopmode/react-file-drop
Gathering detailed insights and metrics for @loopmode/react-file-drop
npm install @loopmode/react-file-drop
Typescript
Module System
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
3
22
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 many hooks so you can use it to develop any custom behavior that you desire.
This is a fork of the original react-file-drop library. It adds support for custom render function for wrappers, and enables it to be used in SVG context.
Furthermore, it accepts any kind of dropped content (not just files) and provides a third argument details
to the onDrop
callback.
http://sarink.github.io/react-file-drop/dist/Demo - A very simple demo with example code and sample CSS
You can grab the demo CSS to get started
✅ Chrome
✅ Firefox
✅ Safari
✅ IE 11
✅ IE Edge
Yup! (For typing event handlers, use the native DragEvent for frame handlers, and the React lib's DragEvent for others)
I wanted that behavior like 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.
npm install 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 <div class="file-drop-target">
will be inserted into the DOM.
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. Check out the Styling section below for details.
If true, any drag/drop is ignored. No callbacks will be invoked.
Callback when the user drops files onto the target
Fork info: the third argument, details, has the signature {files:Array<String>, links:Array<String>, images:Array<String>, text:String, html:String}
Callback when the user is dragging over the target. Also adds the file-drop-dragging-over-target
class to the file-drop-target
Callback when the user leaves the target. Removes the file-drop-dragging-over-target
class from the file-drop-target
Learn more about HTML5 dropEffects. Not available in IE :(
This is the "scope" or frame that the user must drag some file(s) over to kick things off.
Callback when the user begins dragging over the frame
Callback when the user stops dragging over the frame
Callback when the user drops files anywhere over the frame
Component or tag name for rendering the outer wrapper.
Component or tag name for rendering the inner wrapper.
Supported types for outerComponent
and innerComponent
:
div
, span
, g
etc.outerComponent
: className, onDragOver, onDragLeave, onDrop
innerComponent
: className
<FileDrop outerComponent={MyReactComponent}>
<FileDrop outerComponent={(props) => <span {...props} />} />
By default, the component comes with no styles. You can grab the demo CSS to get you started.
The outer container element
This is the target the user has to drag their files to. It will be inserted into the DOM whenever the user starts dragging over the frame.
The file-drop-dragging-over-frame
class will be added to the file-drop-target
whenever the user begins dragging a file over the frame
, and it will be removed when they leave
The file-drop-dragging-over-target
class will be added to the file-drop-target
whenever the user begins dragging a file over the file-drop-target
div, and it will be removed when they leave
No vulnerabilities found.
No security vulnerabilities found.