Skip to content
Alea0.1

Forms

FileUpload

Drop files or browse for them, with sizes, progress and errors in a list.

Ant Design: Upload, Upload.Dragger

import { FileUpload, DropZone } from '@alea/ui';

Examples

FileUpload

Drop or browse; wrong types and big files are flagged.

Drop your logoPNG or SVG, up to 2 MB

Several files

Multiple files with a size limit; each can be removed with the keyboard.

AttachmentsPDF or images, up to 10 MB each

Props

FileUpload props

Drop files or browse for them, with a list that shows size, progress and errors (Ant's Upload.Dragger).

PropTypeDefaultDescription
acceptstring[]-Accepted types, e.g. ['image/png', '.svg'].
allowsMultiplebooleantruePick or drop more than one. Default true.
classNamestring-Extra class names for the root element.
descriptionReactNode-Help under it: types and size.
filesUploadFile[]-The files (controlled), with progress and errors you set.
isDisabledboolean-Disables every part of it.
labelReactNode'Drop files here'The text in the drop area.
maxSizenumber-Largest size in bytes; bigger files are listed with an error.
onChange((files: UploadFile[]) => void)-Called with the full new list when files are added or removed.

DropZone props

A bare drop target, for custom layouts. Keyboard users get the button inside.

PropTypeDefaultDescription
childrenrequiredReactNode-The children of the component. A function may be provided to alter the children based on component state.

Accessibility

  • Keyboard and screen reader users use the Browse button; the drop area is also focusable.
  • Each file has a remove button named after the file.

Keyboard

KeyDoes
Enter or Space (on the zone)Opens the file picker
TabMoves to each file's remove button

Do and don't

Do

  • Say what types and sizes work.

Don't

  • Don't start uploading before people can see what they picked.
Tested with axe, keyboard and screen reader roles