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

@asphalt-react/file-uploader

v2.12.1

Published

FileUploader

Readme

FileUploader

npm npm version

Overview

The FileUploader component is a tool for simplifying file uploads in React applications. It supports file selection through a traditional file picker or drag-and-drop functionality, with customizable intents and multiple variants to suit different use cases. The component offers flexible sizing, accessibility features like keyboard navigation and screen reader support. It handles file validation errors, supports multiple file uploads, and allows customization of labels and qualifiers, making it adaptable to a wide range of file upload scenarios.

Usage

import { FileUploader } from '@asphalt-react/file-uploader'

const accept = {
  'image/png': ['.png'],
  'text/html': ['.html', '.htm']
}

const onChange = (acceptedFiles, {rejectedFiles, event}) => {}

<FileUploader drop onChange={onChange} accept={accept} multiple />

Variants & Intents

There are 2 variations of FileUploader:

  1. Inline

The inline version is a simpler variant that does not support drag and drop functionality. It provides a straightforward file selection interface where users can click a button to open the native file picker dialog. This variant is ideal for use cases where drag and drop is not necessary or desired.

  1. Drag and drop

The drag and drop version includes a dropzone area where users can drag and drop files for upload. This variant enhances the user experience by providing a visual cue for file upload and supports multiple file selection simultaneously.

Drag and drop variant comes with 2 different intents:

  • primary
  • secondary

There are multiple combinations of the action button that can be used in both variants:

  1. secondary brand
  2. secondary system
  3. tertiary brand
  4. tertiary system

Accept File Types

By providing accept prop you can make the component accept specific file types and reject the others. The value must be an object with a common MIME type as keys and an array of file extensions as values.

const accept = {
  'image/png': ['.png'],
  'text/html': ['.html', '.htm']
}

<FileUploader accept={accept} />

Accessibility

  1. The component will render native input type=file in the HTML. It will be read by screen reader as an input element.

  2. FileUploader works with keyboard navigation. Pressing enter when the component is on focused, will trigger opening the file explorer window.

  3. aria-invalid and aria-disabled according to the invalid and disabled prop values.

  4. FileUploader accepts the input form aria-* attributes.

Props

accept

The value must be an object with a common MIME type as keys and an array of file extensions as values. For example:

accept={{ 'image/*': ['.jpg', '.png'], 'video/*': ['.mp4'] }}

| type | required | default | | -------- | -------- | ------- | | objectOf | false | {} |

brand

Applies brand styling.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

system

Applies system styling.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

secondary

Applies secondary styling.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

tertiary

Applies tertiary styling.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

caption

Caption text for the file uploader action button.

| type | required | default | | ------ | -------- | ------------- | | string | false | "Browse File" |

description

Description text for the file uploader.

| type | required | default | | ------ | -------- | ----------------------- | | string | false | "Choose file to upload" |

title

Title text for the file uploader.

| type | required | default | | ------ | -------- | -------------- | | string | false | "Upload Files" |

disabled

Disable the file uploader.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

drop

Enable or disable drag and drop functionality.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

invalid

Marks the file uploader as invalid.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

maxFiles

Maximum number of files that can be selected.

| type | required | default | | ------ | -------- | ------- | | number | false | 0 |

maxSize

Maximum file size in bytes. In case of multiple files, the size is checked for each file.

| type | required | default | | ------ | -------- | ------- | | number | false | N/A |

minSize

Minimum file size in bytes. In case of multiple files, the size is checked for each file.

| type | required | default | | ------ | -------- | ------- | | number | false | 0 |

multiple

Allow multiple file selection.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

onChange

Callback function when file(s) are selected. It returns these values:

  • acceptedFiles: FileList
  • options - an options bucket with the following properties
    • rejectedFiles: Array
      • file: File
      • errors: Array
        • code: string
        • message: string
    • event: DragEvent
function onChange(acceptedFiles, { rejectedFiles, event }) {}

| type | required | default | | ---- | -------- | ------- | | func | false | N/A |

qualifier

Displays an image on top of the dropzone area. By default, an image qualifier is displayed. Use false to hide the default qualifier. Provide an SVG or icon to render a custom qualifier.

| type | required | default | | ----- | -------- | ------- | | union | false | true |

actionQualifier

Add SVG or icon qualifier for action button.

| type | required | default | | ------- | -------- | ------- | | element | false | null |

size

Controls size of FileUploader. Possible values are "xs", "s", "m", "l".

| type | required | default | | ---- | -------- | ------- | | enum | false | "m" |

showFileName

Show the file name after selection.

| type | required | default | | ---- | -------- | ------- | | bool | false | true |

surfacePrimary

Applies primary surface styling.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

surfaceSecondary

Applies secondary surface styling.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |