Socket
Socket
Sign inDemoInstall

@mux/mux-uploader-react

Package Overview
Dependencies
Maintainers
0
Versions
501
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mux/mux-uploader-react

An uploader element for React that handles Mux Direct Uploads and a visual progress bar for you


Version published
Weekly downloads
4.1K
increased by9.2%
Maintainers
0
Weekly downloads
 
Created
Source

<MuxUploader/>

Downloads Version License

Introduction

<MuxUploader> is React component for uploading files to Mux.

<MuxUploaderDrop> is an optional supporting React component for drop-in drag and drop and overlay. You can always configure your own drag and drop with <MuxUploader>.

If you are looking for a direct upload interface and a progress bar, you're in the right place.

Installation

If you're using npm or yarn, install that way:

Package manager

yarn add @mux/mux-uploader-react

or

npm i @mux/mux-uploader-react

Then, import the library into your application with either import or require:

import '@mux/mux-uploader-react';

or

require('@mux/mux-uploader-react');

Usage

const MuxUploaderWithMuxUploaderDropExample = () => {
  return (
    <div>
      <h1>Simple MuxUploader and Mux Uploader Drop Examples</h1>
      {/* Rounded upload button by itself. Displays upload progress in text as percentage. */}
      <MuxUploader endpoint="authenticated-url" style={{ '--button-border-radius': '40px' }}></MuxUploader>

      {/* Upload button by itself. */}
      <MuxUploader endpoint="authenticated-url"></MuxUploader>

      {/* Upload button with access to optional supplentary drag and drop features. */}
      <MuxUploaderDrop mux-uploader="uploader">
        <MuxUploader endpoint="authenticated-url" id="uploader"></MuxUploader>
      </MuxUploaderDrop>
    </div>
  );
};

For a more complex implementation out in the wild, check out stream.new.

Props

<MuxUploader>
PropertyTypeDescriptionDefault
endpointstring | PromiseEither a) the authenticated URL that your file will be uploaded to or b) an async function that yields a promise that resolves to that url. Check out the direct uploads docs for how to create one. Required.undefined
idstringAn ID that allows <MuxUploaderDrop> to locate <MuxUploader>. Required if you use <MuxUploaderDrop>.N/A
dynamicChunkSizebooleanToggles uploading with dynamic chunk sizes. Chunk sizes will change with upload speed to attempt to optimize upload.false
useLargeFileWorkaroundbooleanEnables a less memory-efficient way of loading and chunking files for environments that don't reliably handle ReadableStream for large files. This can occur on e.g. Safari browsers with files >= 4GB.false
<MuxUploaderDrop>
PropertyTypeDescriptionDefault
overlaybooleanToggles fullscreen overlay on dragover.false
overlayTextstringOptional text to display on dragover when overlay is on.''
muxUploaderstring Must match the id on <MuxUploader>. Required.N/A

Callbacks

<MuxUploader>

<MuxUploader> has a handful of a number of callbacks associated with events to handle uploading state.

PropDescription
onUploadStartFired when the upload begins.
onChunkAttemptInvoked immediately before a chunk upload is attempted.
onChunkSuccessInvoked when an indvidual chunk is successfully uploaded. Sample response: { detail: { chunk: Integer, attempts: Integer, response: XhrResponse } }
onUploadErrorInvoked when an error occurs in the chunked upload process.
onProgressInvoked continuously with incremental upload progress. This returns the current percentage of the file that's been uploaded. Sample response: { detail: [0..100] }
onSuccessInvoked when the entire file has successfully completed uploading.

Styling

<MuxUploader> and <MuxUploaderDrop> can be styled with standard CSS, but also includes these CSS variables for "under the hood" inline-styling.

<MuxUploader>
NameCSS PropertyDefault ValueDescriptionNotes
--uploader-font-familyfont-familyArialfont family of the componentApplies to other elements as well: upload status and error status
--uploader-font-sizefont-size16pxfont size for text within the componentAlso applies to <MuxUploaderDrop> i.e. overlay text c
--uploader-background-colorbackground-colorinheritbackground color of area surrounding the upload
--button-background-colorbackground#fffbackground color of upload button
--button-border-radiusborder-radius4pxborder radius of the upload button
--button-borderborder1px solid #000000border of the upload button
--button-paddingpadding16px 24pxpadding of the upload button
--button-hover-textcolor#ffftext color of upload button on button hover
--button-hover-backgroundbackground#404040background color of upload button on button hover
--button-active-textcolor#fffcolor of upload button text when button is active
--button-active-backgroundbackground#000000background color of upload button when button is activeApplied via :active pseudo selector
--progress-bar-fill-colorbackground#000000background color for progress bar div
--progress-radial-fill-colorstrokeblackstroke color for circle SVG (wip)
<MuxUploader/>
NameCSS PropertyDefault ValueDescription
--overlay-background-colorbackground-colorrgba(226, 253, 255, 0.95)background color of the overlay div

Keywords

FAQs

Package last updated on 25 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc