WlDialog
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Heading (when no header slot is provided).
Accessible dialog name without a text heading.
Width (CSS), for example "480px".
Modal mode with backdrop.
Button that closes the surface.
Close by clicking the backdrop.
Close with Escape.
Locks page scrolling while the dialog is open.
Opening and closing animation; defaults to WlConfig.motion (true).
Props ariaLabelledby, pt, size, fullscreen, initialFocus, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlButton, WlDialog, WlInput } from "legato-ui";
import { ref } from "vue";
const visible = ref(false);
const title = ref("Team guide");
</script>
<template>
<div class="wl-stack" data-space="md">
<WlButton @click="visible = true">{{ "Open dialog" }}</WlButton><WlDialog
v-model:visible="visible"
header="Material details"
size="lg"
fullscreen="mobile"
initial-focus=".example-dialog-title"
>
<div class="wl-stack" data-space="md">
<WlInput v-model="title" class="example-dialog-title" aria-label="Material" />
<p class="wl-text-body">{{ "Escape closes the dialog and restores focus." }}</p>
</div>
<template #footer><WlButton @click="visible = false">{{ "Done" }}</WlButton></template>
</WlDialog>
</div>
</template>Editing in a dialog
Field with label/hint, save/cancel footer, motion/dismissible settings and afterLeave.
Changes have not been saved yet. Completed closes: 0.
Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlCheckbox, WlDialog, WlField, WlInput } from "legato-ui";
import { ref } from "vue";
const visible = ref(false);
const motion = ref(true);
const dismissible = ref(false);
const title = ref("Release plan");
const saved = ref("");
const left = ref(0);
</script>
<template>
<div class="wl-stack" data-space="lg">
<div class="wl-inline" data-space="md">
<WlCheckbox v-model="motion">{{ "Dialog animation" }}</WlCheckbox>
<WlCheckbox v-model="dismissible">{{ "Close on backdrop click" }}</WlCheckbox>
</div>
<div><WlButton variant="primary" @click="visible = true">{{ "Edit title" }}</WlButton></div>
<WlDialog
v-model:visible="visible"
header="Edit material"
width="min(480px, calc(100vw - 32px))"
:motion="motion"
:dismissible="dismissible"
:pt="{ footer: { style: { flexWrap: 'wrap' } } }"
@after-leave="left++"
>
<WlField label="Title" hint="The result is saved only in this example.">
<template #default="{ id, ariaDescribedby }">
<WlInput :id="id" v-model="title" :aria-describedby="ariaDescribedby" />
</template>
</WlField>
<template #footer>
<WlButton variant="ghost" @click="visible = false">{{ "Cancel editing" }}</WlButton>
<WlButton variant="primary" :disabled="!title.trim()" @click="saved = title; visible = false">
{{ "Save title" }}
</WlButton>
</template>
</WlDialog>
<p class="wl-text-small" role="status">
{{ saved ? "Saved: " + saved : "Changes have not been saved yet." }}
{{ "Completed closes:" }} {{ left }}.
</p>
</div>
</template>