Alert Dialog
A modal dialog for confirmations and other actions that require an explicit response.
Loading preview…
1<script lang="ts">
2 import { buttonVariants } from "$registry/items/components/button";
3 import * as AlertDialog from "./index.js";
4</script>
5
6<AlertDialog.Root>
7 <AlertDialog.Trigger class={buttonVariants({ variant: "outline" })}
8 >Show Dialog</AlertDialog.Trigger
9 >
10 <AlertDialog.Content>
11 <AlertDialog.Header>
12 <AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
13 <AlertDialog.Description>
14 This action cannot be undone. This will permanently delete your account
15 and remove your data from our servers.
16 </AlertDialog.Description>
17 </AlertDialog.Header>
18 <AlertDialog.Footer>
19 <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
20 <AlertDialog.Action>Continue</AlertDialog.Action>
21 </AlertDialog.Footer>
22 </AlertDialog.Content>
23</AlertDialog.Root>
24Installation
1. Install dependencies
2. Copy these files into your project
- ~/components/alert-dialog/index.ts
- ~/components/alert-dialog/alert-dialog.svelte
- ~/components/alert-dialog/alert-dialog-trigger.svelte
- ~/components/alert-dialog/alert-dialog-portal.svelte
- ~/components/alert-dialog/alert-dialog-overlay.svelte
- ~/components/alert-dialog/alert-dialog-content.svelte
- ~/components/alert-dialog/alert-dialog-header.svelte
- ~/components/alert-dialog/alert-dialog-footer.svelte
- ~/components/alert-dialog/alert-dialog-title.svelte
- ~/components/alert-dialog/alert-dialog-description.svelte
- ~/components/alert-dialog/alert-dialog-action.svelte
- ~/components/alert-dialog/alert-dialog-cancel.svelte
- ~/components/alert-dialog/alert-dialog-media.svelte
Usage
Use alert dialog for destructive or high-impact actions that need confirmation before continuing.
Compose with Trigger, Content, Header, Title, Description, Footer, Cancel, and Action.
1<script lang="ts">
2 import * as AlertDialog from '~/components/alert-dialog';
3 import { buttonVariants } from '$lib/components/ui/button';
4</script>
5
6<AlertDialog.Root>
7 <AlertDialog.Trigger class={buttonVariants({ variant: 'outline' })}
8 >Show Dialog</AlertDialog.Trigger
9 >
10 <AlertDialog.Content>
11 <AlertDialog.Header>
12 <AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
13 <AlertDialog.Description>
14 This action cannot be undone. This will permanently delete your account and remove your data
15 from our servers.
16 </AlertDialog.Description>
17 </AlertDialog.Header>
18 <AlertDialog.Footer>
19 <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
20 <AlertDialog.Action>Continue</AlertDialog.Action>
21 </AlertDialog.Footer>
22 </AlertDialog.Content>
23</AlertDialog.Root>