Confirm deletion
Ask for an explicit decision before removing data that cannot be recovered.
Components / Overlays
A confirmation modal that initially focuses its cancel action.
Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.
bunx --bun @getweini/cli@latest add alert-dialogImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import AlertDialog from './components/ui/alert-dialog/AlertDialog.vue'
import AlertDialogAction from './components/ui/alert-dialog/AlertDialogAction.vue'
import AlertDialogCancel from './components/ui/alert-dialog/AlertDialogCancel.vue'
import AlertDialogContent from './components/ui/alert-dialog/AlertDialogContent.vue'
import AlertDialogDescription from './components/ui/alert-dialog/AlertDialogDescription.vue'
import AlertDialogFooter from './components/ui/alert-dialog/AlertDialogFooter.vue'
import AlertDialogHeader from './components/ui/alert-dialog/AlertDialogHeader.vue'
import AlertDialogTitle from './components/ui/alert-dialog/AlertDialogTitle.vue'
import AlertDialogTrigger from './components/ui/alert-dialog/AlertDialogTrigger.vue'
</script>
<template>
<AlertDialog>
<AlertDialogTrigger>Delete project</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this project?</AlertDialogTitle>
<AlertDialogDescription>The project and its files will be removed.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="$emit('delete')">Delete project</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>Clicking the backdrop does not dismiss an alert dialog. Use AlertDialogHeader’s #icon slot to place an icon beside the title. The body scrolls when content is long, and focus starts on Cancel.
Ask for an explicit decision before removing data that cannot be recovered.
Explain the scope of a high-impact update before applying it.
Cancel receives initial focus.
<script setup lang="ts">
import AlertDialog from './components/ui/alert-dialog/AlertDialog.vue'
import AlertDialogAction from './components/ui/alert-dialog/AlertDialogAction.vue'
import AlertDialogCancel from './components/ui/alert-dialog/AlertDialogCancel.vue'
import AlertDialogContent from './components/ui/alert-dialog/AlertDialogContent.vue'
import AlertDialogDescription from './components/ui/alert-dialog/AlertDialogDescription.vue'
import AlertDialogFooter from './components/ui/alert-dialog/AlertDialogFooter.vue'
import AlertDialogHeader from './components/ui/alert-dialog/AlertDialogHeader.vue'
import AlertDialogTitle from './components/ui/alert-dialog/AlertDialogTitle.vue'
import AlertDialogTrigger from './components/ui/alert-dialog/AlertDialogTrigger.vue'
</script>
<template>
<AlertDialog>
<AlertDialogTrigger>Delete project</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this project?</AlertDialogTitle>
<AlertDialogDescription>The project and its files will be removed.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="$emit('delete')">Delete project</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>Use controlled state when the parent coordinates the operation.
<script setup lang="ts">
import { ref } from 'vue'
import AlertDialog from './components/ui/alert-dialog/AlertDialog.vue'
import AlertDialogAction from './components/ui/alert-dialog/AlertDialogAction.vue'
import AlertDialogCancel from './components/ui/alert-dialog/AlertDialogCancel.vue'
import AlertDialogContent from './components/ui/alert-dialog/AlertDialogContent.vue'
import AlertDialogDescription from './components/ui/alert-dialog/AlertDialogDescription.vue'
import AlertDialogFooter from './components/ui/alert-dialog/AlertDialogFooter.vue'
import AlertDialogHeader from './components/ui/alert-dialog/AlertDialogHeader.vue'
import AlertDialogTitle from './components/ui/alert-dialog/AlertDialogTitle.vue'
import AlertDialogTrigger from './components/ui/alert-dialog/AlertDialogTrigger.vue'
const open = ref(false)
</script>
<template>
<AlertDialog v-model:open="open">
<AlertDialogTrigger>Publish all</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Publish all drafts?</AlertDialogTitle>
<AlertDialogDescription>
Every draft will become visible to your team.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Keep drafts</AlertDialogCancel>
<AlertDialogAction @click="$emit('publish')">Publish all</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
openmodel | boolean | undefined | Not set | Current open state. Use v-model:open to keep it in sync with your page. |
defaultOpenprop | boolean | undefined | false | Starting open state when the parent does not control open. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
update:openevent | [open: boolean] | — | Requests a new open value from the parent. |
openChangeevent | [open: boolean] | — | Emitted after this value or state changes. |
defaultslot | {} | Optional | Content shown inside AlertDialog. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
asChildprop | boolean | undefined | Not set | Use one child element as the control instead of adding another wrapper. |
defaultslot | {} | Optional | Content shown inside AlertDialogAction. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside AlertDialogBody. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
asChildprop | boolean | undefined | Not set | Use one child element as the control instead of adding another wrapper. |
defaultslot | {} | Optional | Content shown inside AlertDialogCancel. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
fullscreenprop | boolean | undefined | false | Fill the available viewport with the dialog content. |
sizeprop | DialogSize | undefined | "md" | Choose the visual size. Medium is the usual default where available. |
dismissOnBackdropprop | boolean | undefined | false | Allow a click outside the dialog content to close it. |
persistentprop | boolean | undefined | Not set | Keep the dialog open when the backdrop is clicked. |
defaultslot | {} | Optional | Content shown inside AlertDialogContent. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside AlertDialogDescription. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside AlertDialogFooter. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | () => unknown | Required | Content shown inside AlertDialogHeader. |
iconslot | (() => unknown) | undefined | Optional | Content for the icon area of AlertDialogHeader. |
actionsslot | (() => unknown) | undefined | Optional | Content for the actions area of AlertDialogHeader. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside AlertDialogTitle. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
asChildprop | boolean | undefined | Not set | Use one child element as the control instead of adding another wrapper. |
defaultslot | {} | Optional | Content shown inside AlertDialogTrigger. |
// packages/frameworks/vue/components/alert-dialog/types.ts
// ------- IMPORTS -------
import type { DialogContentProps, DialogProps, DialogTriggerProps } from '../dialog/types'
// ------- TYPES -------
export type AlertDialogProps = DialogProps
export type AlertDialogContentProps = DialogContentProps
export type AlertDialogTriggerProps = DialogTriggerProps
// packages/frameworks/vue/components/dialog/types.ts
// ------- TYPES -------
export type DialogSize = 'sm' | 'md' | 'lg' | 'xl'
export interface DialogProps {
open?: boolean
defaultOpen?: boolean
disabled?: boolean
}
export interface DialogContentProps {
fullscreen?: boolean
size?: DialogSize
dismissOnBackdrop?: boolean
persistent?: boolean
}
export interface DialogTriggerProps {
disabled?: boolean
asChild?: boolean
}
export interface DialogCloseProps {
asChild?: boolean
}