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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-droplet

v0.1.0

Published

A lightweight, customizable React drag-and-drop file uploader built with TypeScript. Drop files directly, click to upload, and easily handle validation for accepted file types.

Readme

React Droplet

A lightweight, customizable React drag-and-drop file uploader built with TypeScript.
Drop files directly, click to upload, and easily handle validation for accepted file types.


Features

  • Drag & drop files or click to upload
  • Supports single or multiple files
  • File type validation with accept prop
  • Disabled mode with customizable styles
  • Fully customizable icon, label, and droplet styles
  • TypeScript support
  • Easily extendable with event handlers

📚 Full Documentation

👉 View the complete docs here:
https://react-droplet.vercel.app

Installation

npm install react-droplet
# or
yarn add react-droplet

How to use it?

import React from "react";
import Droplet from "react-droplet";

function App() {
  const handleUpload = (files: File[]) => {
    console.log("Uploaded files:", files);
  };

  const handleInvalidFiles = ({ error, invalidFiles }: any) => {
    console.error(error, invalidFiles);
  };

  return (
    <div>
      <h1>React Droplet Demo</h1>
      <Droplet
        accept=".jpg,.png,.pdf"
        multiple
        onUploadFiles={handleUpload}
        onInvalidFiles={handleInvalidFiles}
      />
    </div>
  );
}

export default App;

Props

Props

| Prop | Type | Default | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------- | | accept | string | undefined | Comma-separated file extensions that are allowed (e.g., ".png, .jpg"). | | multiple | boolean | false | Allows selecting or dropping multiple files. | | icon | (ref: React.RefObject<any>) => ReactElement | undefined | Custom icon renderer. Receives iconRef. | | label | (ref: React.RefObject<any>) => ReactElement | undefined | Custom label renderer. Receives labelRef. | | onUploadFiles | (files: File[]) => void | undefined | Called when valid files are uploaded. | | onInvalidFiles | ({ error: string; invalidFiles: File[]; validFiles: File[] }) => void | undefined | Called when some files do not match the accepted extensions. | | classnames | { droplet?: Classname; icon?: Classname; label?: Classname }Classname:{ default?: string; onDisabled?: string; onDragOver?: string } | undefined | Custom class names for each component part. | | disabled | boolean | false | Disables clicking, dragging, and file uploads. | | handleOnClick | ({ event: MouseEvent<HTMLDivElement>, dropletRef, inputRef, iconRef, labelRef, removeDragOverStyle }) => void | undefined | Custom click handler. Prevents the default “open file browser”. | | handleOnInputChange | ({ event: ChangeEvent<HTMLInputElement>, dropletRef, inputRef, iconRef, labelRef, removeDragOverStyle }) => void | undefined | Custom handler when a file is selected via the (input) click. | | handleOnDrop | ({ event: DragEvent<HTMLDivElement>, dropletRef, inputRef, iconRef, labelRef, removeDragOverStyle }) => void | undefined | Custom drop handler that overrides default upload logic. | | handleOnDragOver | ({ event: DragEvent<HTMLDivElement>, dropletRef, inputRef, iconRef, labelRef }) => void | undefined | Custom drag-over handler overriding default hover styles. | | handleOnDragLeave | ({ event: DragEvent<HTMLDivElement>, dropletRef, inputRef, iconRef, labelRef, removeDragOverStyle }) => void | undefined | Custom drag-leave handler. | | children | ({ iconRef: RefObject<any>, labelRef: RefObject<any> }) => ReactElement | undefined | Fully replaces internal UI. Receives iconRef and labelRef. |

How to override UI completely using children prop

<Droplet>
  {({ iconRef, labelRef }) => (
    <div className="my-custom-ui">
      <span ref={iconRef}>🌤️</span>
      <p ref={labelRef}>Upload your files</p>
    </div>
  )}
</Droplet>

Note: To customize entire droplet, you need to use children property with iconRef and labelRef. When you set references of icon and label, it will automatically apply the default behavior of the droplet.

Override default styles

You can fully customize the look of your droplet by using the classnames prop to override the built-in CSS classes. Each part of the component - the root droplet, icon, and label - supports three style states: default for normal appearance, onDisabled when disabled, and onDragOver when a file is dragged over the zone. By providing your own class names for these keys, you replace the default styling with your own, allowing seamless integration with Tailwind, Bootstrap, or any CSS setup you prefer.Note: To fully override the default styles of the droplet-especially during the disabled and drag-over states-you may need to use !important in your CSS for certain default styles.

import Droplet from "react-droplet";

function App() {
  return (
    <Droplet
      classnames={{
        droplet: {
          default: "custom-droplet",
          onDisabled: "custom-droplet-disabled",
          onDragOver: "custom-droplet-hover",
        },
        icon: {
          default: "custom-icon",
          onDisabled: "custom-icon-disabled",
          onDragOver: "custom-icon-hover",
        },
        label: {
          default: "custom-label",
          onDisabled: "custom-label-disabled",
          onDragOver: "custom-label-hover",
        },
      }}
    />
  );
}

export default App;

📚 Full Documentation

👉 View the complete docs here:
https://react-droplet.vercel.app