Skip to main content

UploadButton

Package​

@rpldy/upload-button

Installation​

npm install @rpldy/upload-button

OR

npm install @rpldy/uploady @rpldy/upload-button
note

Must be rendered inside (child/descendant) of an Uploady instance

Props​

Name (* = mandatory)TypeDefaultDescription
idstringundefinedid attribute to pass to the button element
textstring"Upload"the button text (in case no children passed)
classNamestringundefinedthe class attribute to pass to the button element
childrenReact.Nodeundefinedchild element(s) to render inside the button (replaces text)
extraPropsObjectundefinedany other props to pass to the button component (with spread)
refReact refundefinedwill be passed to the button element to acquire a ref
onClickReact.MouseEventHandler<E = Element>undefinedfunction to handle button click (called after showing the system's file selection dialog)

In addition, most UploadOptions props can be passed to UploadButton, in order to override configuration passed to the parent Uploady component. See Uploady documentation for detailed list of upload options.

The following guide shows how different upload buttons may use different upload options.

note

Some options cannot be overridden by the button. For example, any prop that influences the file input directly (such as 'multiple')

Example​

import React from "react";
import Uploady from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";

const App = () => (<Uploady
destination={{ url: "https://my-server/upload" }}>
<UploadButton/>
</Uploady>);