2.4.6 • Published 1 year ago

react-files-preview v2.4.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-files-preview

Netlify Status codeql npm

react-files-preview

A file view component for react.

Installation

npm

npm i react-files-preview

yarn

yarn add react-files-preview

Stackblitz - Check It Live

Basic Usage

import { ReactFilesPreview } from 'react-files-preview'
import 'react-files-preview/dist/style.css'  /* import css file*/

function App() {
  return (
    <>
      <ReactFilesPreview />
    </>
  )
}

export default App

Usage with Tailwind CSS

If your project uses Tailwind CSS, you don’t need to import the CSS file directly. Instead, add the following path to the content array in your tailwind.config.js file:

module.exports = {
  content: [
    './src/**/*.{js,jsx,ts,tsx}',
    './node_modules/react-files-preview/dist/*.js', // Add this line
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Props

NameTypeDefaultDescription
filesFile[][]Pass array of file objects for default files
urlstringnullSet image by passing image URL
downloadFilebooleantrueEnables file download
removeFilebooleantrueShow file remove icon on file hover
showFileSizebooleantrueShow file size under files
showSliderCountbooleantrueShow slides count under file slider
disabledbooleanfalseIf true, prevents user to add files by disabling the component
multiplebooleantrueAccepts one or more files
acceptstringComma-separated lists of file types. See MIME Types
maxFileSizenumberMaximum allowed file size in bytes e.g. 1024 x 1024 x 5 == 5MB
maxFilesnumberMaximum files allowed to be added
widthstringbasis-11/12Tailwind CSS flex-basis class https://tailwindcss.com/docs/flex-basis
heightstringTailwind CSS height class https://tailwindcss.com/docs/height
fileWidthstringw-44Tailwind CSS width class https://tailwindcss.com/docs/width
fileHeightstringh-32Tailwind CSS height class https://tailwindcss.com/docs/height
getFilefuncReturns all current files
onChangefuncReturns selected file(s)
onRemovefuncReturns the removed file
onErrorfuncReturns error message as string
onClickfuncReturns file on click
2.4.1

1 year ago

2.4.2

1 year ago

2.4.5

1 year ago

2.4.4

1 year ago

2.4.6

1 year ago

2.4.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago