@ihatecode/react-file-picker
Version:
A file picker component written in React.
65 lines (53 loc) • 1.67 kB
Markdown
Englist | <a href="https://github.com/zctcode/react-file-picker/blob/main/README-zh_CN.md" target="_blank">中文</a>
<p>
<img alt="npm" src="https://img.shields.io/npm/v/@ihatecode/react-file-picker?logo=npm&color=%234ac41c">
<img alt="npm" src="https://img.shields.io/npm/dm/@ihatecode/react-file-picker?logo=npm&color=%234ac41c">
<img alt="GitHub forks" src="https://img.shields.io/github/forks/zctcode/react-file-picker">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/zctcode/react-file-picker">
</p>
**A file picker component written in React.**
```bash
npm install @ihatecode/react-file-picker
yarn add @ihatecode/react-file-picker
pnpm add @ihatecode/react-file-picker
```
```jsx
import React from 'react';
import FilePicker from '@ihatecode/react-file-picker';
import '@ihatecode/react-file-picker/lib/style.css';
const App: React.FC = () => {
return (
<FilePicker
multiple
accept="image/*"
onChange={(files) => console.log(files)}
>
<span>Select files</span>
</FilePicker>
);
};
export default App;
```
Online demo: [https://pjzpz7.csb.app/](https://pjzpz7.csb.app/)
[](https://codesandbox.io/p/sandbox/pjzpz7)
|Property|Type|Optional
|-|-|:-:
|className|string|Y|
|style|object|Y|
|accept|string|Y|
|multiple|boolean|Y|
|directory|boolean|Y|
|draggable|boolean|Y|
|children|any|Y|
|onChange|(files: FileList) => void|Y|
MIT