Guidelines
About File Picker
Use a File Picker when users need to upload a document in a form flow. The File Picker allows any type of file by default, but the desired file type can be specified using the accept
prop. This is a native HTML file picker, <input type="file" />
, so there's currently no drag-and-drop or multiple attachments functionality. Read more about the native file picker on MDN. The input is hidden visually, but still appears in the DOM, so that we're able to apply custom styles in an accessible way.
Accessibility
- Include a visible Label on all form fields.
- Each label must use the
htmlFor
prop that equals theid
of the associated input. - Provide clear identification of required fields in the label or at the start of a form. If you use the required field indicator, include the form key at the start of the form.
- Use the
required
prop to programatically indicate they are required to browsers.
- Use the
- Include inline error text with the error icon on any field that errors to make it visually clear that the field changed. You can also use the "error" variant of Help Text.
- If the File Picker has associated help text or error text, include the
aria-describedby
prop on the File Picker. This should match theid
of the help or error text.
Disabled File Picker
Required File Picker
Internationalization
To internationalize a File Picker, simply pass the i18nNoSelectionText
prop with the translated string. Because the FilePickerButton
is compositional, you already pass the button text as children.
Label
to the File Picker
. This is done with the htmlFor
prop on the label, and the id
prop on the File Picker. Those two need to match. aria-describedby
prop that equals the id
of the help text. This ensures screen readers know the help text ties directly to the File Picker. Error State
Error Messages
Recommended phrasing for File Picker error copy:
Status | Recommended phrasing |
---|---|
Invalid file type | This file is not an accepted format. You can upload [x], [x] and [x] file formats. |
Exceeds file size limit | This file size is too big. You can upload files up to [file limit]. |
Network errors | Something went wrong with the network. Check your internet connection, then try again. |
Too many uploads | We couldn't upload so many files so quickly. Try uploading files more slowly, or try again later. |
Generic error | Something went wrong. Try uploading your files again. |
Feedback
Help us improve this component by providing feedback, asking questions on Slack, or updating this file on GitHub.