1.0.10 • Published 8 months ago

@licuido-ui/ui_file-upload v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

FileUpload

The FileUpload component is a reusable React component that provides an easy way to handle file uploads with various options and features.

Author

Modified

Link

Story Book Link EmptyPage

PlayGround

Try it have a fun codeBox

Installation

npm i @licuido-ui/ui_file-upload

Import component

import { FileUpload } from '@licuido-ui/ui_file-upload';

Usage

import React from 'react';
import { Box } from '@mui/material';
import { FileUpload } from '@licuido-ui/ui_file-upload';

const App = () => {
  const handleUpload = (data) => {
    console.log('Uploaded File:', data.updatedFile.file.name);
    console.log('Total Files Selected:', data.totalFile);
  };

  return (
    <Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
      <FileUpload
        icon={<span>+</span>}
        onClickUpload={handleUpload}
        maxSize="5MB"
        allowedTypes={['jpg', 'jpeg', 'png', 'pdf']}
        svgIcon={<span>SVG</span>}
        pdfIcon={<span>PDF</span>}
        imgIcon={<span>IMG</span>}
        closeIcon={<span>Close</span>}
      />
    </Box>
  );
};

export default App;

/>

Image

alt text alt text alt text

Props

PropTypeDefault ValueDescription
classNamestring''Additional CSS class for the component.
sxSxProps{}Styling props for the component using Material-UI styling system.
iconReact.ReactNodenullIcon to be displayed inside the upload area.
setTotalFileSelected() => void() => {}Callback function to set the total selected files.
placeHolderstring'Drag and drop your files here'Placeholder text displayed inside the upload area.
onClickUpload(data: object) => void() => {}Callback function triggered when a file is uploaded.
maxSizenumber | string'10MB'Maximum allowed file size (formatted string with units like 'MB', 'KB').
isMultipletrue | falsetrueAllow multiple file selection.
rootStyleSxProps{}Styling props for the root container.
cardStyleSxProps{}Styling props for the upload card container.
UploadIconStyleSxProps{}Styling props for the upload icon.
placeHolderStyleSxProps{}Styling props for the placeholder text.
uploadedCardStyleSxProps{}Styling props for the uploaded card container.
uploadedFileBoxStyleSxProps{}Styling props for the uploaded file icon container.
docIconStyleSxProps{}Styling props for the file type icon container.
fileTitleStyleSxProps{}Styling props for the file title text.
fileSizeStyleSxProps{}Styling props for the file size text.
fileRemoveIconStyleSxProps{}Styling props for the file remove icon container.
variant1 | 231Select between two card variants.
TotalFileSelectedany[]An array of currently selected files.
removeIconReact.ReactNodeIcon to be displayed for removing a file.
allowedTypesstring[][]Array of allowed file extensions (e.g., 'jpg', 'pdf').
uploadErrorStyleobject{}Styling props for the upload error message container.
timeoutnumber3000Timeout in milliseconds for uploading progress simulation.
errorMsgStyleobject{}Styling props for the error message container.
fileSizeErrorMsgstring'File size exceeds the limit'Error message displayed when a file exceeds the size limit.
fileTypeErrorMsgstring'Invalid file type'Error message displayed when a file type is not allowed.
svgIconReactElementnullIcon element for SVG files.
pdfIconReactElementnullIcon element for PDF files.
imgIconReactElementnullIcon element for image files (JPG, JPEG, PNG).
closeIconReactElementIcon element for closing a file upload entry.
deleteIconStyleobject{}Styling props for the delete icon.
closeIconStyleobject{}Styling props for the close icon.
acceptFilesstring[][]Array of accepted file types in the input field (e.g., '.jpg', '.png').
inputAcceptstring''Accept attribute value for the input
element (e.g., 'image/*').
uploadButtonTextstring''Text For The Upload Button
uploadButtonStyleobject{}Styling props for the Upload Button
isOrPlaceholderStyleobject{}Styling props for the isOrPlaceholderStyle
isOrPlaceholderbooleanFalseAllow The Text OR
isOrPlaceholderTextstringorString Declares the text or
isOrPlaceholderStyleobject{}Styling props for the
bottomRenderComponentReactNodeReactNodeAllow The React Component
bottomRenderComponentStyleSxPropsSxPropsAllow The styles props
bottomTextLabelstringstringAllow The Text props
bottomTextLabelStylesxPropssxPropsAllow The style props
isUploadErrorbooleanFalseerror throwing for file upload