You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React set of components for managing file uploads and image previews on user inteface. Components were made inspired on other existing libraries (however, those are not dependencies because the idea is to take many good related libraries only as reference and create something new ). Google's Material design principles were also considered in development. Indeed, icons come from Material design icons.
Sample result:
On Drag, Drop and Upload. (also changing view mode from grid to list).
Did you like the project? Don't forget to give us a ⭐ star on github :D
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"
behaviour
"add" | "replace"
"add"
The behaviuor on drop files. "add" option will make Dropzone to add files to the current file list. "replace" option will make Dropzone to replace the current list of files
children
node
true
The content of the component. Normally a list of FileItem components or a label
clickable
boolean
true
If true, the dropzone component itself will be clickable
Extra configuration for uploading, normally an object with headers or bearer token-
fakeUploading
boolean
undefined
If true, this flag will make dropzone to simulate a server upload. Use only in development.
footer
boolean
true
if true, shows the dropzone footer
header
boolean
true
if true, shows the dropzone header
label
string
"Drop your files here"
Label to place when no files selected
localization
"EN-en" | "ES-es"
"EN-en"
The language to present labels. Only English and Spanish are suported for now.
method
"POST" | "PUT" | "PATCH"
"POST"
The method for uploading.
maxFiles
number
7
Max number of files to be accepted. If the value is 1, will click event dialog to allow just asingle file
maxFileSize
number
undefined
max file size allowed in bytes. if not preent, will not be considered on validating the file
maxHeight
string
"500px"
The max height of the container in string format. e.g. '50vh' , '20%', '40em', '1rem'
onChange
Function
undefined
The onChange event occurs when the value of the file list is changed
onChangeView
Function
undefined
Event that ocurs when view mode has changed. First parameter is the current view mode. the selected view mode
onDrop
Function
undefined
The onDrop event occurs when files are dropped indide the Dropzone. Normally used for retrieving the new files dropped
uploadOnDrop
boolean
false
If true, onDrop event will return the list of files, but also will upload the files if url was set, and also config
url
string
undefined
The url endpoint to upload the files
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
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.
value
FIleValidated[]
[ ]
The current list of Files
FileItem API
Props
Name
Type
Default
Description
file
File
undefined
The actual file
hd
boolean
undefined
If present, preview on full screen will be presented in the real image resolution
id
string | number
undefined
identifier for the file
info
boolean
false
If present, the info layer and the info button will ve visible
localization
"EN-en" | "ES-es"
"EN-en"
The language to present labels. Only English and Spanish are suported for now.
onDelete
Function
undefined
A Function of what to do when close button is pressed or clicked
onSee
Function
undefined
A Function of what to do when "see" button is pressed or clicked. Returns as first parameter the image url. If hd present, will return the image url in the real quality. Otherwise, will return a minimized image with less resolution in order to save memory.
preview
boolean
false
If present, and if onSee present, "see" button will be visible and on click will trigger onSee function
uploadMessage
string
undefined
The message to display when server responds
uploadStatus
undefined | "uploading" | "success" | "error"
undefined
The status of the upload process
valid
boolean
false
whether to show a "valid" or "rejected" message ("valid", "denied"). By default valid is false (if not present, it's false too)This value will affect preview behaviour. If not valid, the preview will not be shown, nor the view button even when onSee and preview props are present. The functionality to allow to show preview despite of a not valid image file, is a feature that will be added in future releases.
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.
About
Fancy & simple to use React Library Component for drag’n’drop files