Overlays
Layout
Dialog
A modal window over the page that waits until someone responds or dismisses it. Use it for a task or a decision that needs an answer first.
Install
import { Dialog } from 'vael-ui'Playground
md
center
dialog
center
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Dialog } from 'vael-ui'
const open = ref(false)
</script>
<template>
<Dialog v-model:open="open">
<p>This is the dialog body. Put any content here.</p>
</Dialog>
</template>Motion New
Dialog's motion, and Drawer's and BottomSheet's: values or hooks for its parts (DialogPart), how it opens and closes (morph, linked, exitOrder, resize) and swapped content. false turns it off.
<Dialog
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | overlaypanelheadertitledescriptionbodyfootermaximizeclose | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
swapresize | 'sync' | 'wait' | boolean | Content that changes while it's open crossfades ('sync') or waits for the old view to leave ('wait'), and the box eases to its new size unless resize: false. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Dialog (modal) pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Escape | Closes the dialog, unless closeOnEsc is false. |
| Tab | Moves focus to the next element in the dialog, wrapping from the last to the first. |
| ShiftTab | Moves focus to the previous element in the dialog, wrapping from the first to the last. |
- The panel has
role="dialog", orrole="alertdialog"with theroleprop, andaria-modal="true"while modal.titlewiresaria-labelledbyanddescriptionwiresaria-describedby. - Without
title, such as with a custom#header, passaria-labeloraria-labelledby: attributes go on the panel. The close and maximize buttons have built-in, translated labels. - On open, focus moves to
initialFocus(), else an[autofocus]element, else the first control in the body or footer, else the first focusable element, else the panel. On close, focus returns to the element that opened it.modal: falseturns off the focus trap and the inert page; focus still moves in, and returns on close unless you moved it elsewhere. - Escape closes only the topmost layer. While modal, the rest of the page, or of the
container, isinert; toasts, live regions, tooltips and overlays opened from inside stay usable.