File uploader
<gcds-file-uploader>
Also called: file upload, file input, dropzone.
A file uploader is a space to select and add supporting documentation.
-
GitHub -
Figma
File uploader component preview
On this page
Coding and accessibility for file uploader
Apply required attributes
Always use the following required attributes with gcds-file-uploader:
namelabeluploader-id
Allow multiple files
Use the multiple attribute to allow the selection of more than one file.
Define file types
Use the accept attribute to define the file types that the file uploader can accept.
Add hint text
Use the hint attribute to add hint text.
Hide the label
-
Set the
hide-labelattribute to true to visually hide the label while maintaining it for assistive technologies. -
Avoid adding hint text when the label is hidden.
Add validation and error messages
- Use the
requiredattribute to activate thebuilt-in error messages and validation for file uploader. - Fields with specific input requirements will validate if the entry is invalid, even if it is not required.
- For optional fields that need validation, like email address formats, add
custom validation with a custom error message .
In this section
label
The label attribute defines the label for the file uploader.
<gcds-file-uploader uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
name
The name attribute identifies the file uploader component within a form. It is used to reference the uploaded files when a form is submitted.
<gcds-file-uploader uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
uploader-id
The uploader-id attribute specifies the unique identifier for the file uploader.
<gcds-file-uploader uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
accept
The accept attribute defines the file types the file uploader accepts.
<gcds-file-uploader accept="image/*" uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
autofocus
The autofocus attribute controls whether the file uploader will be focused automatically when the page loads. By default, it is set to false. When set to true, the file uploader is focused on render.
<gcds-file-uploader autofocus uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
disabled
The disabled attribute controls whether the file uploader is disabled or not. By default, it is set to false.
<gcds-file-uploader disabled uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
error-message
The error-message attribute defines the error message to display for an invalid file input.
<gcds-file-uploader error-message="Error message" uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
form
The form attribute specifies the ID of the form that the file uploader belongs to.
<gcds-file-uploader form="form-id" uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
hide-label
The hide-label attribute controls whether the label is hidden or not.
<gcds-file-uploader hide-label uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
hint
The hint attribute defines the hint text displayed under the label.
<gcds-file-uploader hint="Hint / Example message." uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
multiple
The multiple attribute controls whether the user is allowed to select more than one file.
<gcds-file-uploader multiple uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
required
The required attribute controls whether the file input is required or not. When set to true, it adds “required” after the label, and activates the required validator.
<gcds-file-uploader required uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
validate-on
The validate-on attribute defines the validation event for the file uploader.
<gcds-file-uploader validate-on="other" required uploader-id="file-uploader-preview" label="Label" name="file-uploader-preview">
</gcds-file-uploader>
Code builder
Generate an instance of the component you need by selecting its code properties.
-
Explore by choosing different code values to generate the instance you want.
-
Get the code and pull it into your environment.
-
Add any copy you need to the component (like text for a label).
Note: The code builder uses English for all code elements, which follows standard practice.
Help us improve
Have questions or a request? Give feedback on our contact form.
Something's wrong? Raise it through GitHub with an