Skip to content
Oruga
Bulma
Bootstrap
Tailwind

Upload ​

The Upload input component uses HTML's native file input. It allows users to select files from their device for upload. In addition to native input features, it adds support for Drag and drop and clearing the input.

Use it with the Field component to access all the functionalities.

Examples ​

Base ​

html
<section>
    <o-field>
        <o-upload v-slot="{ click }" v-model="file">
            <o-button tag="button" variant="primary" @click="click">
                <o-icon icon="upload" />
                <span>Click to upload</span>
            </o-button>
        </o-upload>
    </o-field>

    <p><b>Selected:</b> {{ file?.name }}</p>
</section>
javascript
import { ref } from "vue";

const file = ref<File>();

Drag&Drop ​

Enable drag and drop using the drag-drop prop. To allow multiple files to be uploaded, set the multiple prop.

html
<section>
    <o-field>
        <o-upload v-model="dropFiles" multiple drag-drop>
            <div style="text-align: center">
                <p>
                    <o-icon icon="upload" size="is-large" />
                </p>
                <p>Drop your files here or click to upload</p>
            </div>
        </o-upload>
    </o-field>

    <div class="tags">
        <span v-for="(file, index) in dropFiles" :key="file.name">
            {{ file.name }}
            <o-button
                icon-left="times"
                size="small"
                native-type="button"
                @click="deleteDropFile(index)">
            </o-button>
        </span>
    </div>
</section>
javascript
import { ref } from "vue";

const dropFiles = ref<File[]>([]);

function deleteDropFile(index): void {
    dropFiles.value.splice(index, 1);
}

Disabled ​

Prevent inputs with the disabled prop.

html
<section>
    <o-field>
        <o-upload disabled>
            <o-button tag="button" variant="primary">
                <o-icon icon="upload" />
                <span>Click to upload</span>
            </o-button>
        </o-upload>
    </o-field>

    <o-field>
        <o-upload drag-drop disabled>
            <div style="text-align: center">
                <p>
                    <o-icon icon="upload" size="is-large" />
                </p>
                <p>Drop your files here or click to upload</p>
            </div>
        </o-upload>
    </o-field>
</section>

Variants ​

Different styles can be achieved with the variant prop.

html
<section>
    <o-field label="Primary">
        <o-upload v-model="file" drag-drop variant="primary" expanded>
            <div style="text-align: center">
                <o-icon icon="upload" /> Hover to see color variant
            </div>
        </o-upload>
    </o-field>

    <o-field label="Secondary">
        <o-upload v-model="file" drag-drop variant="secondary" expanded>
            <div style="text-align: center">
                <o-icon icon="upload" /> Hover to see color variant
            </div>
        </o-upload>
    </o-field>

    <o-field label="Success">
        <o-upload v-model="file" drag-drop variant="success" expanded>
            <div style="text-align: center">
                <o-icon icon="upload" /> Hover to see color variant
            </div>
        </o-upload>
    </o-field>

    <o-field label="Info">
        <o-upload v-model="file" drag-drop variant="info" expanded>
            <div style="text-align: center">
                <o-icon icon="upload" /> Hover to see color variant
            </div>
        </o-upload>
    </o-field>

    <o-field label="Warning">
        <o-upload v-model="file" drag-drop variant="warning" expanded>
            <div style="text-align: center">
                <o-icon icon="upload" /> Hover to see color variant
            </div>
        </o-upload>
    </o-field>

    <o-field label="Danger">
        <o-upload v-model="file" drag-drop variant="danger" expanded>
            <div style="text-align: center">
                <o-icon icon="upload" /> Hover to see color variant
            </div>
        </o-upload>
    </o-field>

    <p><b>Selected:</b> {{ file?.name }}</p>
</section>
javascript
import { ref } from "vue";

const file = ref<File>();

Upload Component ​

Upload one or more files.

html
<o-upload></o-upload>

Props ​

Prop nameDescriptionTypeValuesDefault
acceptSame as native acceptstring-
aria-activedescendantIdentifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.string-
aria-atomicIndicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.Booleanish-
aria-autocompleteIndicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
presented if they are made.
"both" | "inline" | "list" | "none"-
aria-busyIndicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.Booleanish-
aria-checkedIndicates the current "checked" state of checkboxes, radio buttons, and other widgets."mixed" | Booleanish-
aria-colcountDefines the total number of columns in a table, grid, or treegrid.Numberish-
aria-colindexDefines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.Numberish-
aria-colspanDefines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.Numberish-
aria-controlsIdentifies the element (or elements) whose contents or presence are controlled by the current element.string-
aria-currentIndicates the element that represents the current item within a container or set of related elements."date" | "location" | "page" | "step" | "time" | Booleanish-
aria-describedbyIdentifies the element (or elements) that describes the object.string-
aria-detailsIdentifies the element that provides a detailed, extended description for the object.string-
aria-disabledIndicates that the element is perceivable but disabled, so it is not editable or otherwise operable.Booleanish-
aria-dropeffect
deprecated - in ARIA 1.1
Indicates what functions can be performed when a dragged object is released on the drop target.
"copy" | "execute" | "link" | "move" | "none" | "popup"-
aria-errormessageIdentifies the element that provides an error message for the object.string-
aria-expandedIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.Booleanish-
aria-flowtoIdentifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
allows assistive technology to override the general default of reading in document source order.
string-
aria-grabbed
deprecated - in ARIA 1.1
Indicates an element's "grabbed" state in a drag-and-drop operation.
Booleanish-
aria-haspopupIndicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element."dialog" | "grid" | "listbox" | "menu" | "tree" | Booleanish-
aria-hiddenIndicates whether the element is exposed to an accessibility API.Booleanish-
aria-invalidIndicates the entered value does not conform to the format expected by the application."grammar" | "spelling" | Booleanish-
aria-keyshortcutsIndicates keyboard shortcuts that an author has implemented to activate or give focus to an element.string-
aria-labelDefines a string value that labels the current element.string-
aria-labelledbyIdentifies the element (or elements) that labels the current element.string-
aria-levelDefines the hierarchical level of an element within a structure.Numberish-
aria-liveIndicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region."assertive" | "off" | "polite"-
aria-modalIndicates whether an element is modal when displayed.Booleanish-
aria-multilineIndicates whether a text box accepts multiple lines of input or only a single line.Booleanish-
aria-multiselectableIndicates that the user may select more than one item from the current selectable descendants.Booleanish-
aria-orientationIndicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous."horizontal" | "vertical"-
aria-ownsIdentifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
string-
aria-placeholderDefines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
A hint could be a sample value or a brief description of the expected format.
string-
aria-posinsetDefines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.Numberish-
aria-pressedIndicates the current "pressed" state of toggle buttons."mixed" | Booleanish-
aria-readonlyIndicates that the element is not editable, but is otherwise operable.Booleanish-
aria-relevantIndicates what notifications the user agent will trigger when the accessibility tree within a live region is modified."additions removals" | "additions text" | "additions" | "all" | "removals additions" | "removals text" | "removals" | "text additions" | "text removals" | "text"-
aria-requiredIndicates that user input is required on the element before a form may be submitted.Booleanish-
aria-roledescriptionDefines a human-readable, author-localized description for the role of an element.string-
aria-rowcountDefines the total number of rows in a table, grid, or treegrid.Numberish-
aria-rowindexDefines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.Numberish-
aria-rowspanDefines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.Numberish-
aria-selectedIndicates the current "selected" state of various widgets.Booleanish-
aria-setsizeDefines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.Numberish-
aria-sortIndicates if items in a table or grid are sorted in ascending or descending order."ascending" | "descending" | "none" | "other"-
aria-valuemaxDefines the maximum allowed value for a range widget.Numberish-
aria-valueminDefines the minimum allowed value for a range widget.Numberish-
aria-valuenowDefines the current value for a range widget.Numberish-
aria-valuetextDefines the human readable text alternative of aria-valuenow for a range widget.string-
customValidityCustom HTML 5 validation error to set on the form controlstring | ((currentValue: UploadType<unknown, IsMultiple> | null , state: ValidityState) => string) | undefined-""
disabledSame as native disabledboolean-false
dragDropAccepts drag & drop and change its styleboolean-false
expandedUpload will be expanded (full-width)boolean-
From config:
upload: {
  expanded: false
}
formSame as native formstring-
v-modelThe input value state, use v-model to make it two-way bindingFile | object-
multipleSame as native, also push new item to v-model instead of replacingIsMultiple-
nameSame as native namestring-
nativeReplace last chosen files every time (like native file input element)boolean-true
overrideOverride existing theme classes completelyboolean-
requiredSame as native requiredBooleanish-
useHtml5ValidationEnable HTML 5 native validationboolean-
From config:
{
  useHtml5Validation: true
}
variantColor variant of the controlstringprimary, info, success, warning, danger, and any other custom color
From config:
upload: {
  variant: undefined
}

Events ​

Event namePropertiesDescription
update:model-valuevalue object | object[] | File | File[] - updated modelValue propmodelValue prop two-way binding
focusevent Event - native eventon input focus event
blurevent Event - native eventon input blur event
invalidevent Event - native eventon input invalid event

Slots ​

NameDescriptionBindings
beforeAdditional slot before the dragzone
defaultDefault contentclick (event: Event): void - click handler, only needed if a button is used
afterAdditional slot after the dragzone

Class Inspector ​

Classes applied to the element:
➜ Want to know how does the Class Inspector work?
Class propDescriptionPropsSuffixes
rootClass
Class of the root element.
expandedClass
Class of the root element when expanded.
expanded
disabledClass
Class of the root element when disabled.
disabled
variantClass
Class of the root element with variant.
👉 Drag & drop a file to see it in action!
variantprimary
info
warning
danger
dragzoneClass
Class of the drag/drop container element.
dragDrop
dragzoneHoveredClass
Class of the draggable container element when hovered with a file.
👉 Drag & drop a file to see it in action!
dragDrop

Sass Variables ​

Current theme ➜ Oruga

SASS VariableDefault
$upload-draggable-paddingcalc(4 * h.useVar("control-spacer"))
$upload-disabled-opacityh.useVar("control-disabled-opacity")
$upload-draggable-background-colorh.useVar( "control-background-color")
$upload-draggable-border-colorh.useVar("control-border-color")
$upload-draggable-border-styledashed
$upload-draggable-border-radiush.useVar("border-radius")
$upload-draggable-border-widthh.useVar("control-border-width")
$upload-draggable-hover-border-colorh.useVar("secondary")
$upload-draggable-hover-background-colorh.useVar( "control-background-color")

See ➜ 📄 SCSS file

Current theme ➜ Bulma

SASS VariableDefault
$upload-bgtransparent
$upload-dragzone-padding2em
$upload-colorsfile.$file-colors
$upload-border-colorcss.getVar("grey-light")

See ➜ 📄 SCSS file

Current theme ➜ Bootstrap

SASS VariableDefault
$upload-dragzone-bgtransparent
$upload-dragzone-bg-hovertransparent
$upload-dragzone-border-colorvar(--#{$prefix}border-color)
$upload-dragzone-border-color-hovervar(--#{$prefix}dark-bg-subtle)
$upload-dragzone-border-widthvar(--#{$prefix}border-width)
$upload-dragzone-border-radiusvar(--#{$prefix}border-radius)
$upload-dragzone-padding2em
$upload-disabled-opacity0.5

See ➜ 📄 SCSS file

Current theme ➜ Tailwind

SASS VariableDefault

See ➜ 📄 SCSS file

Released under the MIT License.