Skip to main content

Upload Button

<UploadButton /> Component

The UploadButton component renders a button for uploading files. It provides visual feedback during the upload process and supports different styling options. The component can be customized with icons, button text, and additional styling. It also handles file uploads by displaying an upload indicator or the button's icon based on the upload status.

Usage

<UploadButton @accept="jpg,png,svg,gif" @onFileAdded={{this.onFileAdded}} />

Handling the upload:

@action onFileAdded(file) {
this.fetch.uploadFile.perform(
file,
{
path: 'uploads',
type: 'image',
},
(uploadedFile) => {
// Do something with uploaded file
},
() => {
// Handle upload failure
file.queue.remove(file);
}
);
}

Properties

PropertyTypeDescription
nameStringThe name attribute for the file input.
acceptStringSpecifies the types of files that the file input should accept.
onFileAddedFunctionFunction called when a file is added to the upload queue.
labelClassStringCSS class to apply to the label element within the button.
typeStringSpecifies the button type. Defaults to 'default'.
sizeStringSize of the button. Defaults to 'sm'.
iconStringIcon to display on the button. Defaults to "image".
iconClassStringCSS class for the icon.
buttonTextStringText to display on the button when no file is being uploaded.
hideButtonTextBooleanIf true, hides the button text.
outlineBooleanIf true, applies an outline style to the button.