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

@xsolla/xui-uploader

v0.99.0-pr156.1771925061

Published

--- title: Uploader subtitle: File upload component. description: A cross-platform React file uploader component with file selection, preview, and management capabilities. ---

Readme


title: Uploader subtitle: File upload component. description: A cross-platform React file uploader component with file selection, preview, and management capabilities.

Uploader

A cross-platform React file uploader component that provides a button to select files, displays selected files, and allows removing them.

Installation

npm install @xsolla/xui-uploader
# or
yarn add @xsolla/xui-uploader

Demo

Basic Uploader

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function BasicUploader() {
  return (
    <Uploader
      label="Upload file"
      onFilesChange={(files) => console.log('Selected:', files)}
    />
  );
}

Multiple Files

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function MultipleFiles() {
  return (
    <Uploader
      label="Upload documents"
      placeholder="Select multiple files"
      multiple
      onFilesChange={(files) => console.log('Files:', files)}
    />
  );
}

Accept Specific Types

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function ImageUploader() {
  return (
    <Uploader
      label="Upload image"
      placeholder="Select image file"
      accept=".jpg,.jpeg,.png,.gif"
      onFilesChange={(files) => console.log('Images:', files)}
    />
  );
}

Anatomy

import { Uploader } from '@xsolla/xui-uploader';

<Uploader
  label="Label"                     // Label above button
  placeholder="Select files"        // Button text
  accept=".pdf,.doc"                // Accepted file types
  multiple={false}                  // Allow multiple selection
  disabled={false}                  // Disabled state
  size="md"                          // Button size
  onFilesChange={handleFiles}       // File change callback
/>

Examples

Document Upload

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function DocumentUpload() {
  const [files, setFiles] = React.useState<File[]>([]);

  return (
    <div>
      <Uploader
        label="Legal documents"
        placeholder="Upload PDF documents"
        accept=".pdf"
        multiple
        onFilesChange={setFiles}
      />
      {files.length > 0 && (
        <p style={{ marginTop: 8 }}>
          {files.length} file(s) selected
        </p>
      )}
    </div>
  );
}

Profile Image Upload

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function ProfileImageUpload() {
  const handleImageUpload = (files: File[]) => {
    if (files.length > 0) {
      const file = files[0];
      // Create preview URL
      const previewUrl = URL.createObjectURL(file);
      console.log('Preview:', previewUrl);
    }
  };

  return (
    <div style={{ maxWidth: 300 }}>
      <Uploader
        label="Profile picture"
        placeholder="Choose image"
        accept="image/*"
        onFilesChange={handleImageUpload}
        size="sm"
      />
      <p style={{ fontSize: 12, color: '#666', marginTop: 4 }}>
        Recommended: Square image, at least 200x200px
      </p>
    </div>
  );
}

Form with File Upload

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';
import { Input } from '@xsolla/xui-input';
import { Textarea } from '@xsolla/xui-textarea';
import { Button } from '@xsolla/xui-button';

export default function FormWithUpload() {
  const [files, setFiles] = React.useState<File[]>([]);

  const handleSubmit = () => {
    const formData = new FormData();
    files.forEach((file) => formData.append('attachments', file));
    console.log('Submitting with', files.length, 'files');
  };

  return (
    <form
      style={{ display: 'flex', flexDirection: 'column', gap: 16, maxWidth: 400 }}
      onSubmit={(e) => { e.preventDefault(); handleSubmit(); }}
    >
      <Input label="Subject" placeholder="Enter subject" />
      <Textarea label="Message" placeholder="Enter your message" />
      <Uploader
        label="Attachments"
        placeholder="Add attachments"
        multiple
        onFilesChange={setFiles}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
}

Different Sizes

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function UploaderSizes() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
      <Uploader size="xs" placeholder="Extra small" />
      <Uploader size="sm" placeholder="Small" />
      <Uploader size="md" placeholder="Medium" />
      <Uploader size="lg" placeholder="Large" />
      <Uploader size="xl" placeholder="Extra large" />
    </div>
  );
}

Disabled State

import * as React from 'react';
import { Uploader } from '@xsolla/xui-uploader';

export default function DisabledUploader() {
  return (
    <Uploader
      label="Upload (disabled)"
      placeholder="Cannot upload files"
      disabled
    />
  );
}

API Reference

Uploader

UploaderProps:

| Prop | Type | Default | Description | | :--- | :--- | :------ | :---------- | | label | string | - | Label text above the button. | | placeholder | string | "Select files to upload" | Button text. | | accept | string | - | Accepted file types (e.g., ".jpg,.png"). | | multiple | boolean | false | Allow multiple file selection. | | disabled | boolean | false | Disabled state. | | size | "xs" \| "sm" \| "md" \| "lg" \| "xl" | "md" | Button size. | | onFilesChange | (files: File[]) => void | - | Callback when files change. |

File List Display

When files are selected, they appear below the button with:

  • File icon
  • File name (truncated if too long)
  • Remove button (X icon)

Removing a file updates the list and calls onFilesChange with the updated array.

Accept Patterns

| Pattern | Description | | :------ | :---------- | | .pdf | PDF files only | | .jpg,.jpeg,.png | Specific image formats | | image/* | All image types | | video/* | All video types | | .doc,.docx,.pdf | Multiple document types |

Behavior

  • Click button to open native file picker
  • Multiple selection when multiple is true
  • Files accumulate when multiple is true (new selections add to existing)
  • Files replace when multiple is false
  • Each file can be removed individually
  • Hidden native input, styled button

Accessibility

  • Button is keyboard accessible
  • File input is properly associated with the button
  • Remove buttons have appropriate labels
  • Disabled state prevents interaction
  • File list is accessible to screen readers