# Alert Dialog · JGuang UI

> A modal dialog that interrupts the user with important content and expects a response.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `alert-dialog-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install @base-ui/react
```


### Copy and paste the following code into your project.


[View complete source: components/ui/alert-dialog.tsx](/r/jguang-ui/base/alert-dialog.json)


### Update the import paths to match your project setup.


## Usage

```tsx showLineNumbers
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
```

```tsx showLineNumbers
<AlertDialog>
  <AlertDialogTrigger render={<Button variant="outline" />}>
    Show Dialog
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
      <AlertDialogDescription>
        This action cannot be undone. This will permanently delete your account
        from our servers.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Continue</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>
```

## Composition

Use the following composition to build an `AlertDialog`:

```text
AlertDialog
├── AlertDialogTrigger
└── AlertDialogContent
    ├── AlertDialogHeader
    │   ├── AlertDialogMedia
    │   ├── AlertDialogTitle
    │   └── AlertDialogDescription
    └── AlertDialogFooter
        ├── AlertDialogCancel
        └── AlertDialogAction
```

## Basic

A basic alert dialog with a title, description, and cancel and continue buttons.


> Example `alert-dialog-basic`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## Small

Use the `size="sm"` prop to make the alert dialog smaller.


> Example `alert-dialog-small`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## Media

Use the `AlertDialogMedia` component to add a media element such as an icon or image to the alert dialog.


> Example `alert-dialog-media`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## Small with Media

Use the `size="sm"` prop to make the alert dialog smaller and the `AlertDialogMedia` component to add a media element such as an icon or image to the alert dialog.


> Example `alert-dialog-small-media`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## Destructive

Use the `AlertDialogAction` component to add a destructive action button to the alert dialog.


> Example `alert-dialog-destructive`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `alert-dialog-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/alert-dialog


## API Reference

### size

Use the `size` prop on the `AlertDialogContent` component to control the size of the alert dialog. It accepts the following values:

| Prop   | Type                | Default     |
| ------ | ------------------- | ----------- |
| `size` | `"default" \| "sm"` | `"default"` |

For more information about the other components and their props, see the [Base UI documentation](https://base-ui.com/react/components/alert-dialog#api-reference).

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
