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 name | Description | Type | Values | Default |
|---|---|---|---|---|
| accept | Same as native accept | string | - | |
| customValidity | Custom HTML 5 validation error to set on the form control | string | ((currentValue: object | ObjectConstructor | { new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag ): File; prototype: File; } | (object | ObjectConstructor | { new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag | undefined): File; prototype: File; })[] | null | undefined, state: ValidityState) => string) | undefined | - | "" |
| disabled | Same as native disabled | boolean | - | false |
| dragDrop | Accepts drag & drop and change its style | boolean | - | false |
| expanded | Upload will be expanded (full-width) | boolean | - | From config: upload: { |
| v-model | The input value state | File | object | - | |
| multiple | Same as native, also push new item to v-model instead of replacing | boolean | - | |
| native | Replace last chosen files every time (like native file input element) | boolean | - | true |
| override | Override existing theme classes completely | boolean | - | |
| useHtml5Validation | Enable HTML 5 native validation | boolean | - | From config: { |
| variant | Color of the control | string | primary, info, success, warning, danger, and any other custom color | From config: upload: { |
Events
| Event name | Properties | Description |
|---|---|---|
| update:model-value | value object | object[] | File | File[] - updated modelValue prop | modelValue prop two-way binding |
| focus | event Event - native event | on input focus event |
| blur | event Event - native event | on input blur event |
| invalid | event Event - native event | on input invalid event |
Slots
| Name | Description | Bindings |
|---|---|---|
| default | Default content | onclick (event: Event): void - click handler, only needed if a button is used |
Class Inspector
| Class prop | Description | Props | Suffixes | |
|---|---|---|---|---|
| rootClass | Class of the root element. | |||
| expandedClass | Class of the root element when expanded. | expanded | ||
| disabledClass | Class of the root element when disabled. | disabled | ||
| draggableClass | Class of the dragable container element. | dragDrop | ||
| hoveredClass | Class of the dragable container element when hovered. 👉 Drag & drop a file to see it in action! | dragDrop | ||
| variantClass | Class of the dragable container element with variant. 👉 Drag & drop a file to see it in action! | variant | primary |
Sass Variables
Current theme ➜ Oruga
| SASS Variable | Default |
|---|---|
| $upload-draggable-border | 1px dashed var(--#{$prefix}grey-light) |
| $upload-draggable-border-radius | var(--#{$prefix}base-border-radius) |
| $upload-draggable-disabled-opacity | var( --#{$prefix}base-disabled-opacity) |
| $upload-draggable-hover-border-color | var(--#{$prefix}grey) |
| $upload-draggable-padding | 2em |
See ➜ 📄 SCSS file
Current theme ➜ Bulma
| SASS Variable | Default |
|---|---|
| $upload-bg | transparent |
| $upload-draggable-padding | 2em |
| $upload-colors | file.$file-colors |
| $upload-border-color | css.getVar("grey-light") |
See ➜ 📄 SCSS file
Current theme ➜ Bootstrap
| SASS Variable | Default |
|---|---|
| $upload-draggable-bg | transparent |
| $upload-draggable-bg-hover | transparent |
| $upload-draggable-border-color | var(--#{$prefix}border-color) |
| $upload-draggable-border-color-hover | var(--#{$prefix}dark-bg-subtle) |
| $upload-draggable-border-width | var(--#{$prefix}border-width) |
| $upload-draggable-border-radius | var(--#{$prefix}border-radius) |
| $upload-draggable-padding | 2em |
| $upload-disabled-opacity | 0.5 |
See ➜ 📄 SCSS file
