npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

better-file-input

v1.3.2

Published

A JavaScript library for improving HTML File Inputs

Readme

Better File Input

A lightweight vanilla JavaScript library that converts HTML File Inputs into user-friendly, interactive elements with minimal setup required

GitHub npm

Demo

View the live demo here

Installation

CDN (Recommended)

Add the following to the <head> of your document:

<script src="https://unpkg.com/better-file-input"></script>

Manual

  1. Download dist/bfi.js (or dist/bfi.min.js)
  2. Add the following to the <head> of your document:
<script src="relative/path/to/bfi.js"></script>

npm

  1. Install better-file-input with the following command:
npm i better-file-input
  1. Add the following to the <head> of your document:
<script src="./node_modules/better-file-input/dist/bfi.js"></script>

Usage

Simply add class="bfi" to your file inputs to automatically convert them to better file inputs:

<input type="file" class="bfi">            <!-- Single file input -->
<input type="file" class="bfi" multiple>   <!-- Multiple file input -->
<input type="file" class="bfi" disabled>   <!-- Disabled file input -->

Dynamically-created file inputs will not be automatically converted - you need to call bfi_init() after creation to convert them:

// Create new file input with the 'bfi' class
let newInput = document.createElement('input')
newInput.type = 'file'
newInput.classList.add('bfi')
document.body.appendChild(newInput)

// Convert newly created file input to a better file input
bfi_init()

You can call bfi_clear() to programmatically remove files from a converted file input:

bfi_clear()                 // Clear all better file inputs
bfi_clear('#myFileInput')   // Clear the better file input with the id 'myFileInput'

Customization

The bfi_init() function accepts one optional argument - an object containing pre-defined options to customize the look of your better file inputs:

bfi_init({
  'containerColor': '#b8bfd8',                        // The color of the file container
  'labelColor': 'rgb(77, 79, 86)',                    // The color of the file container label
  'fileColor': 'linear-gradient(#84f189, #53b658)',   // The color of the files
  'fileNameColor': 'darkblue',                        // The color of the file names
  'fileInfoColor': 'rgba(55, 55, 55, 0.75)',          // The color of the file size info
  'dragDropBorder': '3px dotted #374f6d'              // The drag & drop border
})

Calling bfi_reset() will reset the styles to their default values