Modal

Examples

simple modal

import { reactive, watch } from 'vue';

export default {
  setup: () => {
    const state = reactive({
      show: false,
    });

    const close = () => (state.show = false);

    return () => (
      <div class="text-center">
        <dv-button onClick={() => (state.show = true)}>open modal</dv-button>

        <dv-modal-base open={state.show} onClose={close}>
          <dv-modal-title onClose={close}>
            Congratulations random Interner user!
          </dv-modal-title>
          <dv-modal-body>
            You've been selected for a chance to get one year of subscription to
            use Wikipedia for free!
          </dv-modal-body>
          <dv-modal-action>
            <dv-button onClick={close}>Yay!</dv-button>
          </dv-modal-action>
        </dv-modal-base>
      </div>
    );
  },
};
tsx

ModalBase

Attributes

namedescriptiontypedefault
disableTeleportdisable teleportbooleanfalse
containera container to mount the modalstring, function, elemntbody
openmodal open statusbooleanfalse
hideMaskhide maskbooleanfalse
maskCloseablemask closeablebooleantrue
onMaskClickmask click event handlerfunction-
escapeCloseableescape closeablebooleantrue
onEscKeyDownesc keydown event handlerfunction-
onCloseclose event handlerfunction-
customcustom node renderany, function-
destroyOnClosedestroy on closebooleanfalse

Slots

namedescription
defaultcontent
customcustom node(this will override default slot)

ModalTitle

Attributes

namedescriptiontypedefault
closableshow close iconbooleantrue
onCloseclose eventfunction-

ModalBody

Attributes

-

ModalAction

Attributes

-