File Dropzone is only available in the React API for SWAN.
File Dropzone
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.
note
and dropNote
are deprecated in SWAN 3.24. These prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system and remove these prop.
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.
If multiple files are dropped onto File Dropzone and multiple file upload is 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.
File Upload pattern
File Dropzone is part of a larger pattern of uploading files. The File Upload pattern ensures users are presented with a consistent UI regardless of the file types uploaded or the specific page navigated to.
For more information, see File Upload.
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
<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.prop | type | required | description | default |
---|---|---|---|---|
note | string | false | ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support.
The text for below the input button when in default state i.e. "or drag and drop here". | null |
dropNote | string | false | ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support.
The text for when a file is dragged onto the drop zone i.e. Drop your files here. | null |
multiFileErrorMessage | string | true | The error message for when multiple files are dropped when single file upload only i.e. You can only upload one file | null |
How does File Dropzone meet your needs?