Shards Vue

Documentation

    Modals

    Creating flexible modal dialogs can be achieved using the <d-modal> component. They feature a series of helpful subcomponents, sizes and various other options that you can use to customize the display and behavior of your modals.

    Basic Example

    <template>
        <div>Modal opened: <span :class="[showModal ? 'text-success' : 'text-danger']">{{ showModal }}</span></div>
        <d-btn @click.native="handleClick">Click Me</d-btn>
        <d-modal v-if="showModal" @close="handleClose">
            <d-modal-header>
                <d-modal-title>Header</d-modal-title>
            </d-modal-header>
            <d-modal-body>👋 Hello there!</d-modal-body>
        </d-modal>
    </template>
    
    <script>
    export default {
        data() {
            return {
                showModal: false,
            }
        },
        methods: {
            handleClick() {
                this.showModal = true
            },
            handleClose() {
                this.showModal = false
            }
        }
    };
    </script>
    
    <!-- modal-1.vue -->
    

    Modal Size

    Using the size prop on the <d-modal> component, you can control the size of your modal.

    <template>
        <d-btn @click.native="showModal = true">Click Me</d-btn>
        <d-modal v-if="showModal" size="sm" @close="showModal = false" :size="modalSize">
            <d-modal-header>
                <d-modal-title>Hello</d-modal-title>
            </d-modal-header>
            <d-modal-body>
                <div class="mb-3">👋 I'm a <span v-html="modalSize === 'sm' ? 'small' : 'large'" /> modal!</div>
                <d-btn @click="modalSize = modalSize === 'sm' ? 'lg' : 'sm'">Toggle Size</d-btn>
            </d-modal-body>
        </d-modal>
    </template>
    
    <script>
    export default {
        data() {
            return {
                showModal: false,
                modalSize: 'sm'
            }
        }
    };
    </script>
    
    <!-- modal-2.vue -->
    

    Props

    PropDescriptionTypeDefaultRequired
    :tagThe component tag.String"div"False
    :sizeThe size (sm, lg).StringnullFalse
    :no-backdropHides the backdrop overlay.BooleanfalseFalse
    :centeredWhether it is centered, or not.BooleanfalseFalse

    Events

    EventDescription
    @hidden Triggered when the modal is hidden.
    @close Triggered when the modal is closed.

    Subcomponents

    The following subcomponents are available for the <d-modal/> component:

    <d-modal-body/>

    Props
    PropDescriptionTypeDefaultRequired
    :tagThe component's tag.String"div"False

    <d-modal-footer/>

    Props
    PropDescriptionTypeDefaultRequired
    :tagThe component's tag.String"div"False

    <d-modal-header/>

    Props
    PropDescriptionTypeDefaultRequired
    :tagThe component's tag.String"div"False
    :closeWhether to display the close button, or not.BooleantrueFalse

    <d-modal-title/>

    Props
    PropDescriptionTypeDefaultRequired
    :tagThe component's tag.String"h5"False