Skip to content

Commit 1f7ecc5

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 b6ad34d commit 1f7ecc5

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+
Some HTML attributes applied to the input might not work or work differently.
114+
115+
JavaScript creates the improved version of the component out of the file input and then hides the input. The improved version consists of a button with a few `<span>`s.
116+
117+
It takes some of its HTML attributes from the original file input:
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+
- `multiple` is not directly copied but the behaviour of the button is adjusted accordingly
122+
- `aria-describedby` is copied
123+
124+
It leaves some attributes on the original file input because they only work on there, such as:
125+
126+
- `name`
127+
- `accept`
128+
- `capture`
129+
- `accesskey`
130+
131+
To add other attributes to the improved version, you'll have to either add them to the parent `<div>` or via 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)