File inputs and drop areas are used to allow the user to upload and attach files, for instance a receipt to an expense claim.
Use when:
The user needs to upload one or several files.
Use the default file input for uploading files, unless you have special requirements. Be aware that this element looks different in different browsers and operating systems.
Use a drop area for uploading several files.
Behaviour
Indicate the maximum size of uploads if the files can be large, especially since many servers have default limits for uploaded file sizes.
Indicate allowable file types.
If possible, give feedback about upload progress if the files are large.
Drop areas: Files dropped on the dotted area are uploaded.
Drop areas: Indicate by background colour change that drop area is ready for drop when hovering above it with a bunch of files.
File inputs
In cases where the file upload is of less importance or part of a large form, use this file input to draw less attention to it. In cases where the file upload is one of the primary actions, look to adding a drop area instead to highlight its importance.
The functionality for this component, i.e. the script, is not provided and needs to be written by you. The documentation has a demo functionality that you can draw inspiration from in your work.
Design
The simplest design for it is an wrapper with .drop-area class that contain an <input> type file, with the .drop-area-input class, followed by a <label> tag associated to the input with the .drop-area-upload class and a paragraph with the text that will imply that in here can upload.
<pclass="mb-12 font-weight-bold">Default version:</p><divclass="drop-area highlight col-md-6 ml-0"><inputtype="file"id="fileUpload1b"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload1b"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload </p></div><pclass="mb-12 mt-40 font-weight-bold">Compact/small version:</p><divclass="drop-area drop-area-sm highlight col-md-6 ml-0"><inputtype="file"id="fileUpload1d"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload1d"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label></div>
To add an upload indicator/a spinner, just add <span class="spinner"></span> inside the .drop-area wrapper (more options for spinners here). By default the spinner should be hidden, you just need to add .show class when the files were dropped in the drop area and be visible while the user is waiting for the upload to be finished.
Add the aditional .btn class to the <label> tag to add a visible button for upload files. At this point, the only area that can be clicked is the button.
This option is not available for the compact/smaller version.
<divid="drop-area-f"class="drop-area col-md-6 ml-0"><p>Drag and drop documents here to upload </p><inputtype="file"id="fileUpload1f"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload1f"multiple="multiple"class="drop-area-upload btn"tabindex="0">
Choose File
<spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label></div><divid="areaPreviewf"class="drop-area-preview"></div>
Drop area preview zone
You can display the thumbnail images or the file names of the uploaded files. Check the examples below:
Preview the uploaded files outside/below the drop area - compact/small version:
<pclass="mb-32 font-weight-bold">Preview the uploaded files outside/below the drop area - compact/small version:</p><formaction=""class="form-horizontal row"><divclass="col-md-6 ml-0"><divid="drop-area-1"class="drop-area drop-area-sm "><spanclass="spinner"></span><inputtype="file"id="fileUpload1"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload1"multiple="multiple"class="drop-area-upload"tabindex="0"><spanclass="vismaicon vismaicon-dynamic vismaicon-download"></span></label></div></div><divclass="col-12"><divid="areaPreview1"class="drop-area-preview"></div></div></form>
Preview the uploaded files outside/below the drop area - default version:
<pclass="mb-32 font-weight-bold">Preview the uploaded files outside/below the drop area - default version:</p><formaction=""class="form-horizontal"><divid="drop-area-2"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><inputtype="file"id="fileUpload2"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload2"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p></div><divid="areaPreview2"class="drop-area-preview"></div></form>
Preview the uploaded files as text with the file names:
Drag and drop documents here to upload.
Accepted file formats: PNG, JPEG, SVG and PDF.
Maximum file size: 5MB.
<pclass="mb-32 font-weight-bold">Preview the uploaded files as text with the file names:</p><divid="drop-area-3"class="drop-area col-md-6 ml-0"><inputtype="file"id="fileUpload3"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload3"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p></div><divid="areaPreview3"class="drop-area-preview"></div>
Preview the uploaded files as text with the file names in a list:
Drag and drop documents here to upload.
Accepted file formats: PNG, JPEG, SVG and PDF.
Maximum file size: 5MB.
<pclass="mb-32 font-weight-bold">Preview the uploaded files as text with the file names in a list:</p><divid="drop-area-8"class="drop-area drop-area-preview-list col-md-6 ml-0"><inputtype="file"id="fileUpload8"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload8"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p></div><divid="areaPreview8"class="drop-area-preview drop-area-preview-list col-md-6 ml-0"></div>
Preview the uploaded files inside the drop area, with image preview: *this option is not for the compact/smaller version
Drag and drop documents here to upload.
Accepted file formats: PNG, JPEG, SVG and PDF.
Maximum file size: 5MB.
<pclass="mb-32 font-weight-bold">Preview the uploaded files inside the drop area, with image preview:<br>*this option is not for the compact/smaller version</p><divid="drop-area-4"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><inputtype="file"id="fileUpload4"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload4"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><divid="areaPreview4"class="drop-area-preview"></div></div>
Preview the uploaded files inside the drop area, file names as text: *this option is not for the compact/smaller version
Drag and drop documents here to upload.
Accepted file formats: PNG, JPEG, SVG and PDF.
Maximum file size: 5MB.
<pclass="mb-32 font-weight-bold">Preview the uploaded files inside the drop area, file names as text:<br>*this option is not for the compact/smaller version</p><divclass="panel-body"><divid="drop-area-5"class="drop-area col-md-8 ml-0"><spanclass="spinner"></span><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><inputtype="file"id="fileUpload5"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload5"multiple="multiple"class="drop-area-upload btn"tabindex="0">
Choose File
<spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><divid="areaPreview5"class="drop-area-preview"></div></div></div>
Preview the uploaded files inside the drop area, file names in a list: *this option is not for the compact/smaller version
Drag and drop documents here to upload.
Accepted file formats: PNG, JPEG, SVG and PDF.
Maximum file size: 5MB.
<pclass="mb-32 font-weight-bold">Preview the uploaded files inside the drop area, file names in a list:<br>*this option is not for the compact/smaller version</p><divid="drop-area-7"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><inputtype="file"id="fileUpload7"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload7"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><divid="areaPreview7"class="drop-area-preview drop-area-preview-list"></div></div>
Drop area with alternative preview zone
Add the aditional .drop-area-preview-alt class to the .drop-area-preview preview zone wrapper. You can use this alternative option in case you'll use the drop area on a white background.
Alternative preview zone inside the drop area, with image preview:
<pclass="mb-32 font-weight-bold">Alternative preview zone inside the drop area, with image preview:</p><formaction=""class="form-horizontal"><divclass="panel"><divclass="panel-body"><divid="drop-area-6"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><inputtype="file"id="fileUpload6"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload6"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><divid="areaPreview6"class="drop-area-preview drop-area-preview-alt"></div></div></div></div></form>
Alternative preview zone inside the drop area, with file names as text:
<pclass="mb-32 font-weight-bold">Alternative preview zone inside the drop area, with file names as text:</p><formaction=""class="form-horizontal"><divclass="panel"><divclass="panel-body"><divid="drop-area-9"class="drop-area col-md-8 ml-0"><spanclass="spinner"></span><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><inputtype="file"id="fileUpload9"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload9"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><divid="areaPreview9"class="drop-area-preview drop-area-preview-alt"></div></div></div></div></form>
Alternative preview zone inside the drop area, with file names as list:
<pclass="mb-32 font-weight-bold">Alternative preview zone inside the drop area, with file names as list:</p><formaction=""class="form-horizontal"><divclass="panel"><divclass="panel-body"><divid="drop-area-10"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><inputtype="file"id="fileUpload10"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload10"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><divid="areaPreview10"class="drop-area-preview drop-area-preview-alt drop-area-preview-list"></div></div></div></div></form>
Alternative preview zone outside the drop area, with image preview:
<pclass="mb-32 font-weight-bold">Alternative preview zone outside the drop area, with image preview:</p><formaction=""class="form-horizontal"><divclass="panel"><divclass="panel-body"><divid="drop-area-11"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><inputtype="file"id="fileUpload11"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload11"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p></div><divid="areaPreview11"class="drop-area-preview drop-area-preview-alt"></div></div></div></form>
Alternative preview zone outside the drop area, with file names as text:
<pclass="mb-32 font-weight-bold">Alternative preview zone outside the drop area, with file names as text:</p><formaction=""class="form-horizontal"><divclass="panel"><divclass="panel-body"><divid="drop-area-12"class="drop-area col-md-8 ml-0"><spanclass="spinner"></span><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><inputtype="file"id="fileUpload12"class="drop-area-input"aria-label="File Upload"><labelfor="fileUpload12"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label></div><divid="areaPreview12"class="drop-area-preview drop-area-preview-alt"></div></div></div></form>
Alternative preview zone outside the drop area, with file names as list:
<pclass="mb-32 font-weight-bold">Alternative preview zone outside the drop area, with file names as list:</p><formaction=""class="form-horizontal"><divclass="panel"><divclass="panel-body"><divid="drop-area-x"class="drop-area col-md-6 ml-0"><spanclass="spinner"></span><p>Drag and drop documents here to upload.</p><p>Accepted file formats: PNG, JPEG, SVG and PDF.</p><p>Maximum file size: 5MB.</p><inputtype="file"id="fileUploadx"class="drop-area-input"aria-label="File Upload"><labelfor="fileUploadx"multiple="multiple"class="drop-area-upload"tabindex="0"><spanaria-hidden="true"class="vismaicon vismaicon-dynamic vismaicon-download"></span></label></div><divid="areaPreviewx"class="drop-area-preview drop-area-preview-alt drop-area-preview-list col-md-6 ml-0"></div></div></div></form>