Uploading files. The file input component allows a user to provide required files, one at a time.
When to consider something else
Documentation is optional. Avoid asking users to provide documents if you don’t require them.
Asynchronous upload. The file input component doesn’t support asynchronous uploading. Files are POSTed only on form submission.
Asking for large files. Be mindful that some users might have limited connectivity or data plans.
How this component works
Pair with a label. Be sure to provide label text with the file input component.
Prefer one file per input. The file input component only supports one file upload at a time. Some users might not know how to select multiple files in a file browser. Additionally, iOS does not allow multiple-file selection using the Files app.
Highlight input restrictions. Use hint-text to be clear about any file restrictions, such as file types or maximum size.
Trigger: The file input button triggers a micro-interaction that causes the Operating System (OS) to present a dialog that prompts the user to select a file to upload.
Rules: Once the file is uploaded, the browser presents a dialog to inform the user of the success or failure of the upload. The uploaded file can then be removed by the user, if necessary. Additional files can be uploaded, one by one.
Feedback: The Progress bar - Activity component should be used to provide feedback to the user while the file is uploading.
A comma-separated list of unique file type specifiers.
The text displayed on the button.
Emit component-library-analytics events on the file input change event.
The error message to render.
The label for the file input.
The name for the input element.
Sets the input to required and renders the (*Required) text.
The event used to track usage of the component. This is emitted when the
file input changes and enableAnalytics is true.
The event emitted when the file input value changes.
Use explicit and specific words for actions. We prefer “upload” and “delete” as those words describe exactly what will happen when you tap or click.
Upload instead of add. Use the word “Upload” instead of “Add”. For example, “Upload file” and “Upload another file”.
Delete instead of remove. Use the word “Delete” instead of “Remove”. For example, “Delete file”. Also, do not use “Edit” unless the uploaded file can actually be edited in place. “Edit” is not appropriate for an uploaded file if the user has to delete and re-upload the file.
Use file instead of document. File is the broadest term and thus preferable to “document” as that may be too specific when images, text files, and other file types may be acceptable for upload.
Follow messaging guidance. Follow the feedback messages in the messages dictionary for file upload success and failure.
Use proper labels and attributes. When a label is supplied to the label property of the component, it will be associated with the <input> element that has a matching id attribute automatically.