Skip to content

Commit 8acfc33

Browse files
Add guidance about HTML attributes to File Upload component
Co-authored-by: Calvin Lau <77630796+calvin-lau-sig7@users.noreply.github.com>
1 parent c3695da commit 8acfc33

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/components/file-upload/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ This example shows you how to enable the improved File upload component:
108108

109109
{{ example({ group: "components", item: "file-upload", example: "enhanced", html: true, nunjucks: true, open: false, size: "m" }) }}
110110

111+
### About HTML attributes
112+
113+
JavaScript creates the improved version of the component out of the input (`<input type="file">`) and then hides the input from the user. The improved version consists of a `<button>` with a few `<span>` elements inside.
114+
115+
Some HTML attributes applied to the input might not work or work differently.
116+
117+
These attributes must stay in the original input since they're used by the button:
118+
119+
- `id` and its value are added to the button and renamed on the input
120+
- `disabled` is copied and synchronised with any changes that happen on the input
121+
- `aria-describedby` is copied
122+
123+
These attributes must stay in the original input since they only work in the input (and not the button):
124+
125+
- `name`
126+
- `accept`
127+
- `capture`
128+
- `accesskey`
129+
- `multiple`, which also changes the behaviour of the button as text is added when multiple files are selected
130+
131+
To add any other attributes to the improved version, you'll have to add them either to the parent `<div>` or through JavaScript to the button.
132+
133+
Screen readers will not read out the `required` attribute in the improved version. Although we [recommend not to use that attribute](/patterns/validation/#turn-off-html5-validation).
134+
111135
### Changes in the improved component
112136

113137
To make it easier for users to drag and drop files, we’ve made the drop zone:

0 commit comments

Comments
 (0)