项目作者: sunify

项目描述 :
Simple and customizable react file input with a11y in mind
高级语言: JavaScript
项目地址: git://github.com/sunify/react-file-button.git
创建时间: 2019-01-09T11:53:59Z
项目社区:https://github.com/sunify/react-file-button

开源协议:MIT License

下载


React File Button

Simple and customizable react file input with a11y in mind.

Install

yarn add react-file-button/npm install react-file-button --save

Use

  1. import FileButton from 'react-file-button';
  2. const customButtonStyle = {
  3. background: '#0fc',
  4. fontSize: 18,
  5. border: 0,
  6. padding: '20px 40px',
  7. borderRadius: 4,
  8. color: '#000',
  9. display: 'inline-block',
  10. };
  11. <FileButton
  12. multiple
  13. renderButton={(value, files) => (
  14. <div style={customButtonStyle}>
  15. {files.length ? `Files chosen: ${files.length}` : 'Chose files'}
  16. </div>
  17. )}
  18. />;

Props

All input props available plus renderButton: (value: string, files: FileList | []) => ReactNode that renders a custom button. Takes two arguments: value and files and should return react node. className and style properties will apply on component root (label).


Latest version uses hooks and requires react@16.7.0-alpha.x to work. You can use 1.x version if don’t want that.