1.0.20 • Published 4 years ago

react-simple-dropzone v1.0.20

Weekly downloads
96
License
ISC
Repository
github
Last release
4 years ago

React-simple-dropzone

Description

Simple, easy to use dropzone with preview for react. With a small, light bundle size of 130kb, it contains only the necessary functionnalities written with vanilla javascript. It includes also drag and drop images from browser (within the same website or another website).

Examples

  • Use the dropzone and retrieve uploaded image in blob format:
import React, {useState} from 'react';
import Dropzone from 'react-simple-dropzone/dist';

function App() {
  const [image, setImage] = useState(null);
  return (
    <Dropzone onSuccessBlob={ (img) => setImage(img) } />
  );
}
export default App;
  • Use the dropzone and retrieve uploaded image in base64 format:
import React, {useState} from 'react';
import Dropzone from 'react-simple-dropzone/dist';

function App() {
  const [image, setImage] = useState(null);
  return (
    <Dropzone onSuccessB64={ (img) => setImage(img) } />
  );
}
export default App;
  • Multiple images dropzone with preview with a custom display text and error handler:
import React, {useState} from 'react';
import Dropzone from 'react-simple-dropzone/dist';

function App() {
  const [image, setImage] = useState(null);
  const [error, setError] = useState(null);
  return (
    <Dropzone multiple="true" preview="true" displayText="Choisissez un fichier ou faites glisser un fichier ici" onError={ (err) => setError(err) } />
  );
}
export default App;

Screenshots

npm.io

Drag and drop images from a website.

npm.io

Image preview.

npm.io

Browse files with click.

Properties (props)

PropDescriptionReturnDefault value
onSuccessB64Event called when the image drop is successfulbase64 image formatundefined
onSuccessBlobEvent called when the image drop is successfulBlob image formatundefined
onErrorEvent called when the image drop has failederror messageundefined
displayTextThe text to display inside the dropzonereadOnly prop"Drag & Drop images or click to upload"
previewEnable/disable file previewreadOnly proptrue
validTypesValid file types that dropzone acceptsreadOnly prop'image/jpeg', 'image/png', 'image/gif'
acceptFile types/signatures that dropzone acceptsreadOnly prop"image/*"
dragFromWebEnable/disable drag and drop from websitesreadOnly proptrue
multipleEnable/disable multiple file uploadreadOnly propfalse
maxSizeMax size of file to drop in bytesreadOnly prop10e6
clearOnInputEnable/disable clear preview when input new filesreadOnly proptrue

Changelog

  • Earlier versions: Not stable.
  • Version 1.0.19: Most stable basic version with onSuccessB64 and onSuccessBlob props.
  • Version 1.0.20: Will have (onError, displayText, validTypes, accept, dragFromWeb, clearOnInput, preview, maxSize and multiple) props available.
1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.9

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago