Skip to content

Dialog

Modal dialog component for displaying important information or requiring user confirmation with elegant entrance animations.

Basic Usage

The simplest dialog usage, centered by default with scale animation.

vue
<template>
  <u-button @click="visible = true" color="primary">Open Dialog</u-button>
  <u-dialog v-model="visible">
    <u-card>
      <u-card-title>Basic Dialog</u-card-title>
      <u-card-text>
        <p>This is a basic dialog.</p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false" color="primary" variant="text">OK</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

Custom Width

Set dialog width via width prop.

vue
<template>
  <u-button @click="visible = true" color="success">Custom Width</u-button>
  <u-dialog v-model="visible" width="400px">
    <u-card>
      <u-card-title>Custom Width</u-card-title>
      <u-card-text>
        <p>This dialog has a width of 400px.</p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false" color="primary">OK</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

Disable Close on Mask Click

Prevent dialog from closing when clicking the mask.

vue
<template>
  <u-button @click="visible = true" color="warning">
    Disable Mask Close
  </u-button>
  <u-dialog v-model="visible" :close-on-click="false">
    <u-card>
      <u-card-title>Disable Mask Close</u-card-title>
      <u-card-text>
        <p>Clicking the mask won't close this dialog.</p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false" color="primary">OK</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

Fullscreen Dialog

Display dialog in fullscreen mode with slide-up animation.

vue
<template>
  <u-button @click="visible = true" color="error">Fullscreen Dialog</u-button>
  <u-dialog v-model="visible" fullscreen>
    <u-card>
      <u-card-title>Fullscreen Mode</u-card-title>
      <u-card-text>
        <p>This is a fullscreen dialog.</p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false" color="primary">Close</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

Custom Background and Radius

Customize dialog background color and border radius.

vue
<template>
  <u-button @click="visible = true" color="primary">Custom Style</u-button>
  <u-dialog v-model="visible" bgColor="var(--u-success-50)" radius="16px">
    <u-card>
      <u-card-title>Custom Style</u-card-title>
      <u-card-text>
        <p>This dialog has a custom background color and rounded corners.</p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false" color="primary">OK</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

Location

Set the animation origin location via location prop.

vue
<template>
  <u-button @click="visible = true" color="primary">Top Location</u-button>
  <u-dialog v-model="visible" location="top">
    <u-card>
      <u-card-title>Top Animation</u-card-title>
      <u-card-text>
        <p>This dialog animates from the top of the screen.</p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false" color="primary">OK</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

Confirm Dialog

Standard confirmation dialog pattern with button group.

vue
<template>
  <u-button @click="visible = true" color="primary">Confirm Dialog</u-button>
  <u-dialog v-model="visible">
    <u-card>
      <u-card-title>Confirm Delete</u-card-title>
      <u-card-text>
        <p>
          Are you sure you want to delete this record? This action cannot be
          undone.
        </p>
      </u-card-text>
      <div class="dialog-actions">
        <u-button @click="visible = false">Cancel</u-button>
        <u-button @click="visible = false" color="error">Delete</u-button>
      </div>
    </u-card>
  </u-dialog>
</template>

<script setup>
  import { ref } from 'vue';
  const visible = ref(false);
</script>

UDialog API

PropertyDescriptionTypeDefault
modelValueWhether to show the dialogbooleanfalse
widthDialog widthstring'520px'
fullscreenWhether to use fullscreen modebooleanfalse
closeOnClickWhether to close on mask clickbooleantrue
closeOnEscWhether to close on ESC keybooleantrue
bgColorDialog background colorstring'var(--u-bg)'
radiusDialog border radiusstring'4px'
zIndexDialog z-indexnumber1000
locationAnimation origin location'bottom' | 'top' | 'center''bottom'

UDialog Slots

SlotDescription
defaultDialog content
triggerTrigger element

UDialog Events

EventDescription
update:modelValueEmitted when visibility changes
closeEmitted when dialog closes