WlDialog
Appearance
Full example
<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>Behavior
Full example
<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.
Full 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>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model:visible: booleanv-model:visible — whether open (default false).
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
header | string | Not set | Heading (when no header slot is provided). |
modal | boolean | true | Modal mode with backdrop. |
closable | boolean | true | Button that closes the surface. |
dismissible | boolean | false | Close by clicking the backdrop. |
closeOnEscape | boolean | true | Close with Escape. |
blockScroll | boolean | true | Locks page scrolling while the dialog is open. |
ariaLabel | string | Not set | Accessible dialog name without a text heading. |
ariaLabelledby | string | Not set | ID of the element labelling the dialog. |
width | string | | Not set | Width (CSS), for example "480px". |
motion | boolean | Inherits WlConfig.motion | Opening and closing animation; defaults to WlConfig.motion (true). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
size | WlOverlaySize | Not set | Size within the component family's documented scale. |
fullscreen | boolean | | Not set | Expand the dialog to fill the viewport. |
initialFocus | WlOverlayInitialFocus | Not set | Initial focus policy or target for the opened modal surface. |
Events
| Event | Payload | When emitted |
|---|---|---|
open | [] | Dialog fully opened. |
close | [] | Dialog closed. |
afterLeave | [] | Closing transition completed and dialog DOM removed. |
update:visible | boolean | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: {}): unknown; | Dialog body. |
header | header?(props: {}): unknown; | Custom header. |
footer | footer?(props: {}): unknown; | Footer (buttons). |
Pass-through: pt
Sections WlDialog are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
mask | div.wl-dialog-mask | The mask section in WlConfig.pt.dialog configuration. |
root | section.wl-dialog | The root section in WlConfig.pt.dialog configuration. |
header | header.wl-dialog__header | The header section in WlConfig.pt.dialog configuration. |
title | span.wl-dialog__title | The title section in WlConfig.pt.dialog configuration. |
headerActions | div.wl-dialog__actions | The headerActions section in WlConfig.pt.dialog configuration. |
closeButton.root | button.wl-overlay-close | Button that closes the surface. |
closeButton.icon | span | Decorative icon inside the close button. |
content | div.wl-dialog__content | The content section in WlConfig.pt.dialog configuration. |
footer | footer.wl-dialog__footer | The footer section in WlConfig.pt.dialog configuration. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Pass header or ariaLabel/ariaLabelledby, especially with a custom header slot.
- A modal dialog traps focus; Escape and explicit cancellation close it and restore focus to the trigger button.
- Associate the label and error text with the field. Motion respects reduced-motion; after afterLeave, closed-window markup is removed.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move between controls; modal overlays retain focus inside. |
| Escape | Dismiss the top eligible overlay when dismissal is enabled. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model:visible. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.