Modal

Modal component. Based on Headless UI Dialog component.

Usage

Use <Modal /> component to modal/dialog.

View Code
<script setup lang="ts">const isOpen = ref(false)</script><template>  <VButton @click="isOpen = true">    Open Modal  </VButton>  <Modal    v-model="isOpen"  >    <ModalBody>      Your payment has been successfully submitted. We've sent you an email with all of the details of your order.    </ModalBody>  </Modal></template>

With Header

Use <ModalModal /> to add header to the modal.

View Code
<script setup lang="ts">const isOpen = ref(false)</template><template>  <VButton @click="isOpen = true">    Open Modal  </VButton>  <Modal    v-model="isOpen"  >    <ModalHeader>      Payment successful    </ModalHeader>    <ModalBody>      Your payment has been successfully submitted. We've sent you an email with all of the details of your order.    </ModalBody>  </Modal></template>

Dismissable Header

Add dismissable prop to the <ModalHeader /> component to add dismissable button.

View Code
<script setup lang="ts">const isOpen = ref(false)</script><template>  <VButton @click="isOpen = true">    Open Modal  </VButton>  <Modal    v-model="isOpen"  >    <ModalHeader dismissable>      Payment successful    </ModalHeader>    <ModalBody>      Your payment has been successfully submitted. We’ve sent you an email with all of the details of your order.    </ModalBody>  </Modal></template>

Use <ModalFooter /> to add footer to the modal.

View Code
<script setup lang="ts">const isOpen = ref(false)</script><template>  <VButton @click="isOpen = true">    Open Modal  </VButton>  <Modal    v-model="isOpen"  >    <ModalHeader>      Payment successful    </ModalHeader>    <ModalBody>      Your payment has been successfully submitted. We’ve sent you an email with all of the details of your order.    </ModalBody>    <ModalFooter>      <VButton @click="isOpen = false">        Got it, thanks!      </VButton>    </ModalFooter>  </Modal></template>

Persistent

Use persistent to make modal persistent.

View Code
<script setup lang="ts">const isOpen = ref(false)</script><template>  <VButton @click="isOpen = true">    Open Modal  </VButton>  <Modal    v-model="isOpen"    persistent  >    <ModalHeader dismissable>      Payment successful    </ModalHeader>    <ModalBody>      Your payment has been successfully submitted. We’ve sent you an email with all of the details of your order.    </ModalBody>  </Modal></template>

Fullscreen

Use fullscreen to make modal fullscreen.

View Code
<script setup lang="ts">const isOpen = ref(false)</script><template>  <VButton @click="isOpen = true">    Open Modal  </VButton>  <Modal    v-model="isOpen"    fullscreen  >    <ModalHeader dismissable>      Payment successful    </ModalHeader>    <ModalBody>      Your payment has been successfully submitted. We’ve sent you an email with all of the details of your order.    </ModalBody>  </Modal></template>

Props

Prop NameTypeDefault ValueDescription
modelValueBooleanfalseSets the visibility of the modal. When modelValue is set to true, the modal is visible, and when it's set to false, the modal is hidden.
persistentBooleanfalseDetermines whether the modal should persist even when the user clicks outside the modal. By default, the modal will close when the user clicks outside of it. Setting this prop to true will prevent that behavior.
fullscreenBooleanfalseMake modal fullscreen

Events

NamePayloadDescription
update:modelValue{value: boolean}Triggered when modelValue prop changed

Slots

NamePayloadDescription
defaultNoneThe default Vue slot.

Sub Components

  • <ModalHeader />
  • <ModalBody />
  • <ModalFooter />