On this page

Alert dialog

Install, props and the parts Alert dialog is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/alert-dialog.json

Use

<script setup lang="ts">
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from '@/components/ui/alert-dialog'
import { Button } from '@/components/ui/button'
</script>

<template>
  <AlertDialog>
    <AlertDialogTrigger as-child>
      <Button variant="ghost-destructive">Delete mapping</Button>
    </AlertDialogTrigger>
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle>Delete this mapping?</AlertDialogTitle>
        <AlertDialogDescription>You can't undo this.</AlertDialogDescription>
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel>Cancel</AlertDialogCancel>
        <AlertDialogAction variant="destructive">Delete mapping</AlertDialogAction>
      </AlertDialogFooter>
    </AlertDialogContent>
  </AlertDialog>
</template>

Props

Part Prop Values Notes
AlertDialog open, defaultOpen boolean Controlled (v-model:open) or initial state
AlertDialogContent size default, sm 384 px (size.dialog.small) or 320 px (size.dialog.xsmall) wide at most
AlertDialogAction variant, size Button variants and sizes default (Primary) by default; destructive for Danger
AlertDialogCancel variant, size Button variants and sizes outline (Default) by default
AlertDialogMedia A 40 px icon tile beside the title
AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter Parts

To run something before closing, such as a request, listen to @click on AlertDialogAction, or control open and close it when the request ends.

Built on

Wraps the reka-ui AlertDialog with the shadcn-vue AlertDialog API, as control-center ships it. reka-ui gives the alertdialog role and name, focus on Cancel, focus trapping and return, and blocks closing on an outside click. Beehexa adds the styles; the buttons use the Beehexa Button styles.