Skip to content

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

Drag&Drop

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

Disabled

Prevent inputs with the disabled prop.

Variants

Different styles can be achieved with the variant prop.

Upload component

Upload one or more files.

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

Props

Prop nameDescriptionTypeValuesDefault
acceptSame as native acceptstring-
customValidityCustom HTML 5 validation error to set on the form controlstring | ((currentValue: object | ObjectConstructor | { new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag ): File; prototype: File; } | (object | ... 1 more ... | { ...; })[] | null | undefined, state: ValidityState) => string) | undefined-""
disabledSame as native disabledboolean-false
dragDropAccepts drag & drop and change its styleboolean-false
expandedUpload will be expanded (full-width)boolean-false
v-modelThe input value stateFile | object-
multipleSame as native, also push new item to v-model instead of replacingboolean-
nativeReplace last chosen files every time (like native file input element)boolean-true
overrideOverride existing theme classes completelyboolean-
useHtml5ValidationEnable HTML 5 native validationboolean-
From config:
{
  useHtml5Validation: true
}
variantColor 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
defaultDefault contentonclick (event:Event): void - click handler, only needed if a button is used

Class Inspector

Classes applied to the element:
Class propDescriptionPropsSuffixes
rootClassClass of the root element.
expandedClassClass of the root element when expanded.expanded
disabledClassClass of the root element when disabled.disabled
draggableClassClass of the dragable container element.dragDrop
hoveredClassClass of the dragable container element when hovered.
👉 Drag & drop a file to see it in action!
dragDrop
variantClassClass of the dragable container element with variant.
👉 Drag & drop a file to see it in action!
variant
dragDrop
primary
info
warning
danger

Sass variables

Current theme ➜ Oruga

SASS VariableDefault
$upload-draggable-border1px dashed var(--#{$prefix}grey-light)
$upload-draggable-border-radiusvar(--#{$prefix}base-border-radius)
$upload-draggable-disabled-opacityvar( --#{$prefix}base-disabled-opacity)
$upload-draggable-hover-border-colorvar(--#{$prefix}grey)
$upload-draggable-padding2em

See ➜ 📄 Full scss file

Current theme ➜ Bulma

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

See ➜ 📄 Full scss file

Current theme ➜ Bootstrap

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

See ➜ 📄 Full scss file

Released under the MIT License.