The FileDrop component allows users to upload files by dragging and dropping them into a designated area or by clicking to select files from their device. It simplifies the file upload process with an intuitive, user-friendly interface, providing visual feedback and handling multiple files. This component is ideal for applications that require easy and efficient file uploads, improving overall user experience.
FileDrop uses render props to give you more flexibility on what to render at each state change:
isDefault: No file uploaded and no user interaction
isHoverAccept: File is being dragged over and matches the accept string
isHoverReject: File is being dragged over but does not match the accept string
You also have access to:
openFile: To open the native file chooser dialog box
fileUrl: URL of file if one has been opened/dropped (to show a preview)
By default, accept: is set to { "image/*": [] }. See more about showOpenFilePicker and media type.
By default:
title: is set to "Add file"
hint: is set to "Drag & drop a file here or"
fileButtonText: is set to "Browse file"
previewButtonText: is set to "Preview"
You can override translations with a wordings object.
With preview
Image
Other
Sometime in the url we don't have the type of the file, you can override with forceFileType set to image, audio or video.
By default, the filename is retrieved from the url. If you want to display a custom filename, you can use the fileName prop.