<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

File Dropzone

Allows the user to upload one or multiple files from their device. Uploads are initiated via drag and drop or the native OS file picker.
styleKeys: fileDropzone

Use File Dropzone...

  • For uploading one or more files.
  • For uploading files by dragging and dropping.

Don't use File Dropzone...

  • To show the progress of uploading. Use File Tile instead.
  • When space on a page is limited. Use File Input instead.

Default

The File Dropzone component extends the functionality of File Input to include drag and drop functionality.

The preview has been updated.

Inside of a Form

Since it is a form element, File Dropzone can be used inside a Standard Form along with a separate, external label and/or helper text. Helper text should display upload criteria such as accepted file formats and maximum file size.

The preview has been updated.

Single File Upload

When multiple file upload is not enabled (on File Input), add the File Tile as a child of the File Dropzone which applies specific styling for single file upload. When multiple files are dropped on the dropzone and it's not enabled, then the dropzone will show an error on drag and only pass the first file to the input's onChange event.

The preview has been updated.

Disabled

To disable the FileDropzone, add the disabled prop on the FileInput.

The preview has been updated.

Validation

You may want to validate files when the user adds files to the dropzone such as accepted file types, max file size and total number of files. We recommend that you do this during the onChange event of the File Input. An example of some common file validation has been provided below, feel free to copy/paste and update as necessary.

File Input accept prop

Per the validation code snippet below, we have provided an example of sharing the same values in the File Input accept prop for the accepted file validation. Note that this method is recommended but you must only use individual mime types unless you update the validation function to handle wildcards. See a full implementation in the next section.

Full Implementation

This is an example of how you might implement the File Dropzone with File Tiles and file validation. Feel free to take this and tweak as necessary for your use case.

The preview has been updated.

Forms

When using File Dropzone in a form, ensure it is wrapped in its own FormField and FormInputGroup. You can then utilise form components such as FormHelper to provide helper text. When File Tiles are rendered within the same FormField, the component will automatically pick up any errors passed through to File Tile to link them with the File Dropzone. Refer to the Full Implementation example in the Usage tab for more information.

Props

FileDropzone
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
notestringtrue
The text for below the input button when in default state i.e. "or drag and drop here".
null
dropNotestringtrue
The text for when a file is dragged onto the drop zone i.e. Drop your files here.
null
multiFileErrorMessagestringtrue
The error message for when multiple files are dropped when single file upload only i.e. You can only upload one file
null