How to Use Modal Dialog in Vue 3 with Shadcn UI

In this tutorial, we’ll guide you through creating a modal dialog in Vue 3 using Shadcn-Vue. Before we begin, make sure 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 add the alert-dialog component from Shadcn-Vue.

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

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

Vue
<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
Javed sheikh

Hello there! I’m Javed Sheikh, a frontend developer with a passion for crafting seamless user experiences. With expertise in JavaScript frameworks like Vue.js, Svelte, and React, I bring creativity and innovation to every project I undertake. From building dynamic web applications to optimizing user interfaces,

Share link