A modal dialog that interrupts the user with important content and expects a response.
Epicenter
Local-first, open source apps
Installation
Install bits-ui:
Copy and paste the following code into your project.
Usage
<script lang="ts">
import * as AlertDialog from "$lib/components/ui/alert-dialog/index.js";
import { buttonVariants } from "$lib/components/ui/button/index.js";
</script> <AlertDialog.Root>
<AlertDialog.Trigger class={buttonVariants({ variant: "outline" })}>
Show Dialog
</AlertDialog.Trigger>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Description>
This action cannot be undone. This will permanently delete your account
from our servers.
</AlertDialog.Description>
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<AlertDialog.Action>Continue</AlertDialog.Action>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root> Basic
A basic alert dialog with a title, description, and cancel and continue buttons.
Small
Use the size="sm" prop to make the alert dialog smaller.
Media
Use the AlertDialog.Media component to add a media element such as an icon or image to the alert dialog.
Small with Media
Use the size="sm" prop to make the alert dialog smaller and the AlertDialog.Media component to add a media element such as an icon or image to the alert dialog.
Destructive
Use the AlertDialog.Action component to add a destructive action button to the alert dialog.