WUI logo

FileUpload

The File Upload component enables users to select and upload files from their device. It supports both drag-and-drop and traditional file selection methods, providing a straightforward way to manage file uploads. This component is essential for applications that require users to submit documents, images, or other file types, ensuring a smooth and efficient upload experience.

import * as React from 'react'
import { FileUpload } from '@welcome-ui/file-upload'
import { Button } from '@welcome-ui/button'
import { Field } from '@welcome-ui/field'
const Example = () => {
const handleChange = () => {
// your code
}
return (
<Field>
<FileUpload
accept="image/*"
handleAddFile={handleChange}
handleRemoveFile={handleChange}
name="avatar"
onError={() => {
//error
}}
value=""
>
{({ openFile }) => <Button onClick={openFile}>Upload avatar</Button>}
</FileUpload>
</Field>
)
}
export default Example

Installation

1

Run the following command:

yarn add @welcome-ui/file-upload
2

Import component:

import { FileUpload } from '@welcome-ui/file-upload'

Preview

Multiple

Add multiple property.

Disabled

Customize

Button

You can change the upload button component.

Preview

You can change the preview component.

You can also set the preview prop to null and handle your own preview in place of the upload button with files & onRemoveFile render props.