PDF, JPG or PNG. Maximum 5MB.
Default
Nothing chosen yet: the button and the drop text.
Lets people attach a file from their device, like a photo of an ID card or a scanned letter. A multiple version lets people add several files to one question.
Updated
PDF, JPG or PNG. Maximum 5MB.
national-id-card.pdf selected
File upload
Paste this markup in your form
<div class="nds-file-upload nds-file-upload--selected"> <div class="nds-file-upload__label-row"> <label class="nds-file-upload__label" for="upload-your-id-document-input"> Upload your ID document </label> <span class="nds-file-upload__required" aria-hidden="true"> * </span> </div> <div class="nds-file-upload__zone"> <input class="nds-file-upload__input" type="file" id="upload-your-id-document-input" name="upload-your-id-document" accept=".pdf,.jpg,.jpeg,.png" aria-describedby="upload-your-id-document-input-hint" /> <div class="nds-file-upload__file"> <label class="nds-file-upload__change nds-button nds-button--tertiary nds-button--md" for="upload-your-id-document-input"> Change file </label> <div class="nds-file-upload__meta"> <svg class="nds-file-upload__file-icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-file"> </use> </svg> <div class="nds-file-upload__file-text"> <span class="nds-file-upload__name"> national-id-card.pdf </span> <span class="nds-file-upload__details"> PDF, 1.2MB </span> </div> </div> <button type="button" class="nds-file-upload__remove nds-button nds-button--tertiary nds-button--sm nds-button--icon-only" aria-label="Remove national-id-card.pdf"> <svg class="nds-button__icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-close"> </use> </svg> </button> </div> </div> <p class="nds-file-upload__hint" id="upload-your-id-document-input-hint"> PDF, JPG or PNG. Maximum 5MB. </p> <p class="nds-sr-only" id="upload-your-id-document-input-live" aria-live="polite" aria-atomic="true"> national-id-card.pdf selected </p></div> Usage
<!-- wp:nds/file-upload {} --><div class="nds-file-upload nds-file-upload--selected"> <div class="nds-file-upload__label-row"> <label class="nds-file-upload__label" for="upload-your-id-document-input"> Upload your ID document </label> <span class="nds-file-upload__required" aria-hidden="true"> * </span> </div> <div class="nds-file-upload__zone"> <input class="nds-file-upload__input" type="file" id="upload-your-id-document-input" name="upload-your-id-document" accept=".pdf,.jpg,.jpeg,.png" aria-describedby="upload-your-id-document-input-hint" /> <div class="nds-file-upload__file"> <label class="nds-file-upload__change nds-button nds-button--tertiary nds-button--md" for="upload-your-id-document-input"> Change file </label> <div class="nds-file-upload__meta"> <svg class="nds-file-upload__file-icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-file"> </use> </svg> <div class="nds-file-upload__file-text"> <span class="nds-file-upload__name"> national-id-card.pdf </span> <span class="nds-file-upload__details"> PDF, 1.2MB </span> </div> </div> <button type="button" class="nds-file-upload__remove nds-button nds-button--tertiary nds-button--sm nds-button--icon-only" aria-label="Remove national-id-card.pdf"> <svg class="nds-button__icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-close"> </use> </svg> </button> </div> </div> <p class="nds-file-upload__hint" id="upload-your-id-document-input-hint"> PDF, JPG or PNG. Maximum 5MB. </p> <p class="nds-sr-only" id="upload-your-id-document-input-live" aria-live="polite" aria-atomic="true"> national-id-card.pdf selected </p></div><!-- /wp:nds/file-upload --> Usage
import { FileUpload } from "@nigerian-design-standards/react";<FileUpload label="Upload your ID document" required hint="PDF, JPG or PNG. Maximum 5MB." accept=".pdf,.jpg,.jpeg,.png"/> Usage
use NDS\Components\FileUpload;echo FileUpload::render([ 'label' => 'Upload your ID document', 'accept' => '.pdf,.jpg,.jpeg,.png', 'hint' => 'PDF, JPG or PNG. Maximum 5MB.', 'required' => true,]); Use a file upload when a service needs a document as evidence, like an ID, proof of address or a certificate. Ask one question per document, and say the file types and maximum size in the hint.
One file or several. Each has default, selected, error and disabled states; the multiple version adds a list of files.
PDF, JPG or PNG. Maximum 5MB.
Nothing chosen yet: the button and the drop text.
PDF, JPG or PNG. Maximum 5MB.
national-id-card.pdf selected
The file name and size, a Remove button, and Change file.
The selected file must be a PDF, JPG or PNG
PDF, JPG or PNG. Maximum 5MB.
passport-scan.heic selected
An error message, icon and red border. The file name stays on screen.
PDF, JPG or PNG. Maximum 5MB.
Can’t be used. Avoid it where you can and say why instead.
The properties of the file upload. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| label | string |
| Required. Says what to upload. |
| accept | string |
| File types people can choose. Say them in the hint too. |
| maxSize | string |
| Checked when a file is chosen, and again on submit. |
| multiple | boolean |
| Shows a list of files. Set the limit with maxFiles. |
In code, use a real <input type="file"> with <label for>, and aria-describedby pointing to the hint and the
error. Announce the chosen file in a polite live region, like “national-id-card.pdf selected”.
Never replace the input with a div.
| Part | Token | Contrast on the page |
|---|---|---|
| Container | Upload area · surface/canvas · border/strong 1px | 4.2:1 |
| File name | Body/medium-emphasized · text/primary | 17.6:1 |
| Hint and file size | Body/small · text/secondary | 6.6:1 |
| Remove | Button, Icon only, Small, with icon/Close | Uses standard Button tokens |
| Error | status/error/surface: text, icon and border | 4.9:1 |
| Disabled | text/disabled | Not required |
You can only upload 1 file. Choose or drop just one
PDF, JPG or PNG. Maximum 5MB.
When several files land on a one-file field, add none and say why.
PDF, JPG or PNG. Maximum 5MB.
Don’t rely on drag and drop. The button must always work.
How a file upload sits in a form.
How to write hints and error messages.
“Up to 5 files. PDF, JPG or PNG, up to 5MB each.”
“Not added. The file must be smaller than 5MB.”
“Remove national-id-card.pdf”, so people know which one.
“Try again” or “Choose a different file”.
So people can see which file was wrong.
| Write | Don’t write | Why |
|---|---|---|
| Select your ID document | This field is required | Says what to do. |
| The selected file must be a PDF, JPG or PNG | Invalid file type | Names the types allowed. |
| Up to 5 files. PDF, JPG or PNG, up to 5MB each. | Allowed types: pdf, jpg, png | Put the limit in the hint. |
| Not added. The file must be smaller than 5MB. | File too large | Say why a file wasn’t added. |
| The file could not be uploaded. Try again | Upload failed (500) | Say what to do next. |
Meaning never relies on colour alone: an error has an icon and text, and the chosen file is named in words.
| Key | What it does |
|---|---|
| Tab | Moves to Choose file (one tab stop), then to Remove once a file is chosen. |
| Shift + Tab | Moves back. |
| Enter or Space | Opens the file picker; on phones it offers camera, photos and files. On Remove, removes the file and moves focus back to Choose file. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Form/File upload from 01 Library – Foundations. Keep a real file input in the markup.
Is this page useful?