1.0.4 • Published 7 years ago

style-file-input v1.0.4

Weekly downloads
377
License
MIT
Repository
github
Last release
7 years ago

style-file-input

Build Status BrowserStack Status

Style file input element.

Install

npm install style-file-input --save

Usage

Markup

<input type="file" />

Style

@import url('style-file-input');

If you use PostCSS and postcss-import plugin, it will automatically use provided default styling.

Client-side functionality

const stylefileinput = require('style-file-input');
const element = document.querySelector('input[type="file"]');
const instance = stylefileinput(element);

API

stylefileinput(element, options)

Returns: Object

element

Type: Element

Element on which to apply changes.

options

Type: Object

PropertyTypeDefaultDescription
browseButtonLabelString'Browse'Button label for browse action.
changeButtonLabelString'Change'Button label for change action.
noFileSelectedTextString'No file selected'Default input value placeholder.
wrapperClassString'kist-Stylefileinput'Wrapper class.
inputClassString'kist-Stylefileinput-input'Input class.
buttonClassString'kist-Stylefileinput-button'Browse/change button class.
textClassString'kist-Stylefileinput-text'Input value placeholder class.

instance.destroy()

Destroy instance.

Browser support

Tested in IE9+ and all modern browsers.

Caveats

  • Opera Mini doesn’t fire change event when input value is changed so it won’re replace default text.

Acknowledgments

Test

For local automated tests, run npm run test:automated:local (append :watch for watcher support).

For local integration tests, run npm run test:integration:local (append :watch for watcher support).

For manual tests, run npm run test:manual:local and open http://localhost:9000/ in your browser.

License

MIT © Ivan Nikolić
MIT © Filament Group