You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

react-files-preview

Package Overview
Dependencies
1
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-files-preview

A file view component for React apps with images preview, image editing, slider, download option and more.


Version published
Weekly downloads
487
decreased by-24.26%
Maintainers
0
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Package last updated on 27 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc