Components
Upload

Upload

The Upload component enables the publishing of files (such as text, images, and videos) to a remote server using a web interface or an upload tool.

Import

import { VKUpload } from "@vivakits/react-components";

Basic

When the upload button is clicked, a file selection dialog appears, allowing the user to choose files for upload. files and handleFileChange props are required.

Upload

Accepted Files

Specify the types of files allowed for upload using the accepts property to ensure only valid file types are selected.

Upload png file only

Upload image

Upload pdf file only

Upload pdf

Multiple Files

Upload multiple files simultaneously using the multiple property and limit the number of files selected with the maxFiles property.

Upload multiple files

Select Multiple Files for Upload

Limit the number of selected files

Select Files for Upload (Max: 3)

Drag and Drop

Control the drag-and-drop functionality with the allowDragAndDrop property in the Upload component.

Disable drag and drop

Select file to Upload

Example

Here are examples demonstrating how to use the Upload component for selecting files and uploading them directly to the cloud.

Upload on file change

Upload component to select multiple files and upload them to the cloud with a single click.

Upload on button click

Click to upload or drag and drop

Clear all selected files in a single action.

Clear all files

Click to upload or drag and drop

Upload API Reference

AttributeTypeDescriptionDefault
acceptsstringSpecifies the types of files that can be uploaded, ensure file types are specified with a leading dot (e.g., ".png" instead of "png") -
childrenReactNodeAdditional elements or components to be rendered inside the upload box -
clearablebooleanAllows users to remove all files at once. Works only when multiple is truefalse
customClearBtnComponentJSX.ElementCustom clear button component -
customUploadBtnComponentJSX.ElementCustom upload button component -
filesarray[]Array of files to be uploaded -
handleFileChangefunction()Callback function for handling file changes -
handleUploadfunction()Callback function to handle the upload process -
headerComponentJSX.ElementCustom header component for the upload box -
uploadComponentJSX.ElementCustom upload component -
multiplebooleanEnables the selection of multiple files at oncefalse
uploadBoxTextComponentJSX.ElementCustom text component for the upload box -
uploadBoxWrapperClassNameCSSCSS class(es) to style the wrapper of the upload box -
uploadIconComponentJSX.ElementCustom upload icon component -
uploadIconWrapperClassNameCSSCSS class(es) to style the wrapper of the upload icon -
maxFilesnumberLimits the number of files that can be uploaded. Works only when multiple is true. -
classNameCSSCSS class(es) to style the whole upload component. -
allowDragAndDropbooleanControls file drag and drop functionality.true

FileUploadList API Reference

AttributeTypeDescriptionDefault
filesarray[]Array of files to be uploaded -
customFileItemComponentJSX.ElementCustom component for rendering individual file items in the list -
removeIconComponentJSX.ElementCustom remove icon component for each file item -
handleRemovefunction()Callback function to handle file removal from the list -
fileItemWrapperClassNameCSSCSS class(es) to style the wrapper of each file item -
previewWrapperClassNameCSSCSS class(es) to style the preview wrapper of the uploaded files -