nikku / file-drops

A simple in-browser file drop utility.

Home Page:https://www.npmjs.com/package/file-drops

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

file-drops

A simple in-browser file drop utility.

Usage

import fileDrop from 'file-drops';

const element = document.querySelector('#container');

const dropHandler = fileDrop('Drop a file', function(files) {
  // files = [ { name, contents }, ... ]
});

element.addEventListener('dragover', dropHandler);

Styling

On drop over, the utility will attach the following overlay to the element for which the drop handler got registered:

<div class="drop-overlay">
  <div class="box">
    <div class="label">{label}</div>
  </div>
</div>

Style it as you wish. ❤️

See also

License

MIT

About

A simple in-browser file drop utility.

https://www.npmjs.com/package/file-drops

License:MIT License


Languages

Language:JavaScript 100.0%