Upload

Upload one or more files

<template>
    <b-field class="file">
        <b-upload v-model="file">
            <a class="button is-primary">
                <b-icon icon="upload"></b-icon>
                <span>Click to upload</span>
            </a>
        </b-upload>
        <span class="file-name" v-if="file">
            {{ file.name }}
        </span>
    </b-field>
    
</template>

<script>
    export default {
        data() {
            return {
                file: null
            }
        }
    }
</script>

Drag and drop

<template>
    <section>
        <b-field>
            <b-upload v-model="dropFiles"
                multiple
                drag-drop>
                <section class="section">
                    <div class="content has-text-centered">
                        <p>
                            <b-icon
                                icon="upload"
                                size="is-large">
                            </b-icon>
                        </p>
                        <p>Drop your files here or click to upload</p>
                    </div>
                </section>
            </b-upload>
        </b-field>

        <div class="tags">
            <span v-for="(file, index) in dropFiles"
                :key="index"
                class="tag is-primary" >
                {{file.name}}
                <button class="delete is-small"
                    type="button"
                    @click="deleteDropFile(index)">
                </button>
            </span>
        </div>
    </section>
</template>

<script>
    export default {
        data() {
            return {
                dropFiles: []
            }
        },
        methods: {
            deleteDropFile(index) {
                this.dropFiles.splice(index, 1)
            }
        }
    }
</script>

API

Name
Description
Type
Values
Default
v-modelBinding value File, Array<File> []
drag-dropAccepts drag & drop and change its style Boolean false
typeType (color) of the drag area when hovered String is-white, is-black, is-light, is-dark, is-primary, is-info, is-success, is-warning, is-danger, and any other colors you've set in the $colors list on Sassis-primary
disabledSame as native disabled Boolean false
nameSame as native name String -
requiredSame as native required Boolean false
acceptSame as native accept String -
loadingAdd the loading state Boolean false
multipleSame as native, also push new item to v-model instead of replacing Boolean false
nativeReplace last chosen files every time (like native file input element) Boolean false

This page is open source. Noticed a typo or something's unclear?

Improve this page on GitHub