API Reference
UploadButton

UploadButton

A simple button that opens the native file picker and uploads the selected files.

Live demo

The button is shown below, try it out!


Example source code

Props

PropRequiredTypeDescription
uploadUrlYesstring | (() => Promise<string>)Either the absolute upload URL or an async function that generates it
fileTypesNostring[]A list of file type specifiers (opens in a new tab)
multipleNobooleanWhether the user can select multiple files to upload. Defaults to false
onUploadProgressNo(progress: number) => voidCalled every time the combined upload progresses by at least 10 percent. progress % is a multiple of 10.
onUploadBeginNo(fileName: string) => voidCalled at the start of each upload.
onUploadCompleteNo(uploaded: UploadFileResponse[]) => Promise<void> | voidCalled when all the files have been uploaded.
onUploadErrorNo(error: unknown) => voidCalled if there was an error at any point in the upload process.
contentNo(progress: number | null) => stringReplaces the content shown on the button. progress % is a multiple of 10 if the upload is in progress or null.
classNameNo(progress: number | null) => stringReplaces the className of the button. progress % is a multiple of 10 if the upload is in progress or null.