Drop zone

    The drop zone component lets users upload files by dragging and dropping the files into an area on a page, or activating a button.

    Examples

    Down Arrow

    Use to allow merchants to upload files. They can drag and drop files into the dashed area, or upload traditionally by clicking the “Add file” button or anywhere inside the dashed area.


    Best practices

    Drop zone

    Drop zones should:

    • Inform merchants when the file(s) can’t be uploaded:
      • When possible, use validation errors on drag to detect and explain things like file size limits or file types accepted.
      • Use the banner component with a critical status to communicate errors that happen on the server.
    • Provide feedback once the file(s) have been dropped and uploading begins.
    • For convenience, allow files to be dropped anywhere on the page by enabling dropOnPage.
    • Provide a file upload button to allow merchants to select files for upload in a traditional way. Do this by using the DropZone.FileUpload subcomponent.

    Validation errors

    The drop zone component validates file type by default. File types you wish to accept can be defined by editing the accept property. This component also accepts custom validations using the customValidator property. When validation fails, the component sets itself to error mode.


    Content guidelines

    Client-side validation error messages

    Client-side validation errors give instant feedback.

    Validation error messages should be:

    • Explicit: help merchants understand why their file can’t be uploaded and what they should change to successfully upload their file
    • In sentence case: capitalize only the first word in the message
    • Concise: use simple, clear language that can be read at a glance. For example:

    File size must be less than 20MB

    File type must be .gif, .jpg, .png or .svg

    Server-side upload error messages

    Server-side upload errors give feedback after file submission.

    Upload error messages should:

    • Be displayed as a banner with a critical status
    • Show the name of the file(s) that were not uploaded successfully
    • Describe why the file(s) couldn’t be uploaded and what merchants should change to upload their file successfully, as seen below
    The following images couldn’t be uploaded:
    
      ,[object Object], ,[object Object],
    • “so-so-real.png” was interrupted due to weak network connection, ,[object Object],

    Drop zone file upload

    Use file upload with the drop zone component to let merchants select files for upload in a traditional way.

    File upload properties

    PropTypeDescriptionDefault
    actionTitlestringString that appears in file upload'Add file'
    actionHintstringString that appears in file upload'or drop files to upload'


    Accessibility

    See Material Design and development documentation about accessibility for Android:

    See Apple’s Human Interface Guidelines and API documentation about accessibility for iOS:

    The drop zone component builds on the native HTML <input type="upload"> element. It includes a visual<button> as well as a drag and drop area that can receive keyboard focus.

    Keyboard support

    To upload a file with the keyboard, merchants can interact with the drag-and-drop region.

    • To give the input keyboard focus, use the tab key (or shift + tab when tabbing backwards)
    • To activate the input, use the enter/return or space keys