how to use modal dialog in vue 3 with shadcn ui

How to Use Modal Dialog in Vue 3 with Shadcn UI

VueJS
17/10/23
Webvees

In this tutorial, we'll walk you through creating a modal dialog in Vue 3 using Shadcn-Vue. However, before we get started, ensure that you've installed and configured Shadcn UI in your Vue 3 project.

How to Use Shadcn UI in Vue 3

To use Alerts modal dialog you need to shadcn-vue add alert-dialog.

npx shadcn-vue@latest add alert-dialog
# or
npx shadcn-vue@latest add


 Creating Vue 3 Alert Modal Dialogs with Shadcn-Vue Components:

AlertDialog

AlertDialogAction

AlertDialogCancel

AlertDialogContent

AlertDialogDescription

AlertDialogFooter

AlertDialogHeader

AlertDialogTitle

AlertDialogTrigger

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

<template>
  <AlertDialog>
    <AlertDialogTrigger>Open</AlertDialogTrigger>
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
        <AlertDialogDescription>
          This action cannot be undone. This will permanently delete your account
          and remove your data from our servers.
        </AlertDialogDescription>
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel>Cancel</AlertDialogCancel>
        <AlertDialogAction>Continue</AlertDialogAction>
      </AlertDialogFooter>
    </AlertDialogContent>
  </AlertDialog>
</template>
modal dialog in Vue 3 using shadcn-vue

modal dialog in Vue 3 using shadcn-vue