Package Exports
- dropzone-ui
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dropzone-ui) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🚀 Spanish
Dropzone-UI
React set of components for a complete file upload management awith image previews on user inteface. There already exists some very good libraries; However, inspired in those ones, there was created something new and more powerful. Google's Material design principles were also considered in development. Indeed, icons come from Material design icons.
Sample result:
On Drag, Drop, Upload and ful screen preview. (also changing view mode from grid to list).
Did you like the project? Don't forget to give us a ⭐ star on :octocat: github :D



Installation
dropzone-ui is available as an npm package.
For uploading files, peer dependency axios must be installed in conjuction with dropzone-ui.
// with npm
npm i dropzone-ui axios// with yarn
yarn add dropzone-ui axiosUsage and examples
Here is a quick example to get you started, it's all you need:
import React from "react";
import ReactDOM from "react-dom";
import { Dropzone, FileItem } from "dropzone-ui";
Function App() {
const [files, setFiles] = useState([]);
const updateFiles = (incommingFiles) => {
setFiles(incommingFiles);
};
return (
<Dropzone onChange={updateFiles} value={files}>
{files.map((file) => (
<FileItem {...file} preview />
))}
</Dropzone>
);
}
ReactDOM.render(<App />, document.querySelector("#app"));Yes, it's really all you need to get started as you can see in these live and interactive demos:
| Name | Codesandbox link |
|---|---|
| Dropzone Basic example | |
| Dropzone Complete example | |
| File item props | |
| No preview FileItem | |
| InputFileButton & FileItemContainer | |
| Server side example for upload a file | https://github.com/dropzone-ui/file-upload-server-side/tree/main/expressjs |
Dropzone UI Components API
Dropzone API
Props
FileItem API
Props
FullScreenPreview API
Props
| Name | Type | Default | Description |
|---|---|---|---|
| imgSource | string |
undefined |
The url string representation of the image |
| onClose | Function |
undefined |
A function that describes the close behaviour |
| openImage | boolean |
false |
Flag that indicates whether to open the image preview or close it |
FileItemContainer API
Props
| Name | Type | Default | Description |
|---|---|---|---|
| children | node |
true |
The content of he component. Normally a list of FileItem. By default Dropzone component already uses this component for containing the FileItem list children. |
| view | "grid" | "list" |
"grid" |
grid will display files in a grid layout. list will display files in a horizontal list. Convenient for saving space in page. |
InputButton API
Props
| Name | Type | Default | Description |
|---|---|---|---|
| accept | string |
undefined |
A string that contains list of mime types or file extentions(.extention) separated by commas, wich is compared with the file attributes in order to determine whether that file is valid or not E.G.: "image/\*, application/pdf, .psd" |
| color | string |
"#071e25" |
The main color for the button. (e.g. "#FFFFFF", "rgb(255,12,45)") |
| disabled | boolean |
false |
whether the button will be disabled or not |
| id | string |
undefined |
the id of the component |
| label | string |
"Browse ..." | If given, this label will be showed inside the button |
| maxFileSize | number |
undefined |
max file size allowed in bytes |
| multiple | boolean |
false |
whether to accept multiple files or not |
| onChange | Function |
undefined |
What to do after selecting the files. Returns the File[] as first parameter |
| style | React.CSSProperties |
{} | the in-line style object |
| text | "uppercase" | "capitalize" | "lowercase" | "none" |
"capitalize" |
The text transform for the text inside the button label |
| textColor | string |
"white" | The font color in case variant is "contained" |
| validator | (f: File) => boolean |
undefined |
Must be a function that recieves as first parameter a File Object and must return a boolean value. This function will be used instead of the default validator |
| variant | "text" | "outlined" | "contained" |
"contained" |
The variant of the button |
License
This project is licensed under the terms of the MIT license.