Upload
A file input to browse and upload files from local devices, such as computer, laptop, tablet, etc. It has a drag & drop file upload dropzone that can restrict uploadable file types.
For file preview or multiple file uploads, use UploadGrid because it has better UX (user experience). For instance, there is instant preview of selected images and extra information, such as file size.
TODO: Universal Input API, with input file
format
,parse
,normalize
and event action handlers.
Props
Prop | Type | Default | Description |
---|---|---|---|
accept | String | A comma-separated list of one or more file types allowed for upload. Examples of valid values:
For more details, refer to accept specs. | |
children | String |Number |Boolean |Function | Custom label to show inside Upload dropzone, default is placeholder Icon or Text | |
childBefore | String |Number |Boolean |Function | Custom UI to show inside Upload dropzone, before upload__label | |
childAfter | String |Number |Boolean |Function | Custom UI to show inside Upload dropzone, after upload__label | |
hyphen | Boolean |
| Whether to hyphenate Text when it overflows width |
loading | Boolean |
| Whether to show loading spinner and block input interaction |
maxFiles | Number | Maximum number of uploaded files (when | |
maxSize | Byte | Maximum file(s) upload size limit in bytes (accumulative for | |
minSize | Byte | Minimum file(s) upload size limit in bytes (accumulative for | |
multiple | Boolean | Whether to allow upload of more than one file | |
iconSelect | String |
| Icon name for selecting file upload, default style is |
iconRemove | String |
| Icon name for removing file upload, default style is |
square | Boolean | Whether to add | |
value | Array | Input files - if passed, becomes a controlled-like component | |
defaultValue | Array | Initial Input files for uncontrolled-like component | |
onChange | Function | Handler(event, acceptedFiles: File[] | null, name?, self) when input value changes | |
onError | Function |
| Handler(event, {message: String, file?: File}[], name?, self) when input changes and validation fails |
onRemove | Function | Handler(event, removedFiles: File[], name, self, callback) before input files are to be removed, To use custom behavior, set event.preventDefault, then fire The default behavior uses window.confirm() before calling |
Examples
Basic Usage
Upload Configs
File Dropzone
Input Sizes
Input States
Event Handlers
Please refer to Universal File Input for more upload field props.