Gathering detailed insights and metrics for @brainhubeu/react-file-input
Gathering detailed insights and metrics for @brainhubeu/react-file-input
Gathering detailed insights and metrics for @brainhubeu/react-file-input
Gathering detailed insights and metrics for @brainhubeu/react-file-input
⚛️ A file Input, with drag'n'drop and image editor for React
npm install @brainhubeu/react-file-input
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (93.26%)
CSS (5.08%)
Shell (1.66%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
77 Stars
342 Commits
10 Forks
8 Watchers
36 Branches
8 Contributors
Updated on Jul 08, 2025
Latest Version
0.9.20
Package Id
@brainhubeu/react-file-input@0.9.20
Size
85.12 kB
NPM Version
6.14.5
Node Version
12.18.2
Published on
Jul 17, 2020
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
29
21
A File Input, width drag'n'drop and image editor.
An image is worth thousand words
1npm i @brainhubeu/react-file-input
Or if you prefer
1yarn add @brainhubeu/react-file-input
The basic usage is very simple, the only important prop you have to pass is onChangeCallback
:
1import React from 'react'; 2import FileInput from '@brainhubeu/react-file-input'; 3import doSomethingWithMyFile from '../utils/doThings'; 4 5const MyFileUploader = () => ( 6 <div> 7 <FileInput 8 label='Awesome Uploader' 9 onChangeCallback={doSomethingWithMyFile} 10 /> 11 </div> 12); 13 14export const MyFileUploader;
And your set and ready to do something with your file
.
See the reference below for more advanced usages.
Probably you are not crazy enough to handle your forms like in 1999. Chances are that you are using redux-form
. If so, it's your lucky day, because you can use our FileInput
with redux-forms
. Here's a basic example:
1// MyFileInput.js 2import React, { PureComponent } from 'react'; 3import FileInput from '@brainhubeu/react-file-input'; 4 5export default class MyFileInput extends PureComponent { 6 constructor(props) { 7 super(props); 8 9 this.onChange = this.onChange.bind(this) 10 } 11 onChange({ value }) { 12 const { input } = this.props; 13 14 input.onChange(value); 15 } 16 render() { 17 const { input, label } = this.props; 18 19 return ( 20 <FileInput 21 label='Awesome Uploader' 22 onChangeCallback={this.onChange} 23 onDragEnterCallback={input.onFocus} 24 onDragLeaveCallback={input.onBlur} 25 /> 26 ); 27 } 28}
1// MyGreatForm.js 2import MyFileInput from './MyFileInput' 3 4... 5 6<Field name="myField" component={MyFileInput}/>
And that's it. Prepare some coffee and enjoy.
The Component comes with custom css
. You must import them using our component (if not things will look wrong). Of course you could also override them ;)
1// index.js 2import React from 'react'; 3import { render } from 'react-dom'; 4 5import App from './App'; 6 7import '@brainhubeu/react-file-input/dist/react-file-input.css'; 8 9render( 10 <App />, 11 document.getElementById('app') 12);
Or if you prefer from your stylesheet directly:
1@import "~@brainhubeu/react-file-input/dist/react-file-input.css"; 2 3// very good css here...
You can customize the styles of the different components passing classnames as a prop:
propName | description |
---|---|
className | Custom className |
dropAreaClassName | Custom className for the DropArea |
fileInfoClassName | Custom className for the FileInfo |
imageEditorClassName | Custom className for the ImageEditor |
Those classnames are for the top main components. But if you want to override child styles you can writing some css
. Here's how you can do so:
1.myCustomClassName { 2 .brainhub-file-input__label { 3 font-size: 10px; 4 color: #ccc; 5 } 6}
Take a look on the styles and selectors here: https://github.com/brainhubeu/react-file-input/tree/master/src/styles
The internal state of the FileInput
is important to you, because the callbacks will be call with it as argument.
name | type | description |
---|---|---|
value | File or null | Selected file |
image | string or null | If file is an image, the image in base64 |
propName | type | required | default | description |
---|---|---|---|---|
className | string | no | '' | Custom className |
dropAreaClassName | string | no | '' | Custom className for the DropArea |
fileInfoClassName | string | no | '' | Custom className for the FileInfo |
imageEditorClassName | string | no | '' | Custom className for the ImageEditor |
dragOnDocument | boolean | no | true | Listen for drag events in the whole document |
dropOnDocument | boolean | no | false | Allow to drop on document |
label | string | yes | Label for the input | |
metadataComponent | React Component | no | null | Custom component for the metadata. Props: name , size , extension , type |
thumbnailComponent | React Component | no | null | Custom component for the image thumbnail. Props: children (<img> node with the thumbnail) |
displayImageThumbnail | boolean | no | true | Whether to generate a thumbnail for image files |
cropAspectRatio | number | no | 0 | If cropTool is enabled, the aspect ratio for the selection. 0 means the selection is free |
cropTool | boolean | no | false | Wheter to render a crop tool for image files |
scaleOptions | {width: number, height: number: keepAspectRatio: boolean} | no | null | Scale option for file images. keepAspectRatio refers to if the original aspect ratio should be kept when appliyin scaling |
onChangeCallback | function | no | null | Callback invoked when a file is selected. It is called with the current state of the component |
onDragEnterCallback | function | no | null | Callback invoked when drag enters. It is called with the current state of the component |
onDragLeaveCallback | function | no | null | Callback invoked when drag leaves. It is called with the current state of the component |
To run the example, type:
1cd docs-www
and
1npm run develop 2// or 3yarn develop
if you want to run a local version of react-file-input, please use:
1npm run develop:local 2// or 3yarn develop:local
And go to http://localhost:8000
react-file-input is copyright © 2018-2020 Brainhub It is free software, and may be redistributed under the terms specified in the license.
react-file-input is maintained by the Brainhub development team. It is funded by Brainhub and the names and logos for Brainhub are trademarks of Brainhub Sp. z o.o.. You can check other open-source projects supported/developed by our teammates here.
We love open-source JavaScript software! See our other projects or hire us to build your next web, desktop and mobile application with JavaScript.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
198 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More