# 警告对话框 · JGuang UI

> 要求用户确认关键操作的模态对话框。

- 页面: https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/alert-dialog
- 改编自: shadcn/ui 文档 (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c
- 说明：正文保留英文原文。

> 示例 `alert-dialog-demo`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/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 radix-ui
```


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


[View complete source: components/ui/alert-dialog.tsx](/r/jguang-ui/radix/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 asChild>
    <Button variant="outline">Show Dialog</Button>
  </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.


> 示例 `alert-dialog-basic`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/alert-dialog


## Small

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


> 示例 `alert-dialog-small`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/alert-dialog


## Media

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


> 示例 `alert-dialog-media`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/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.


> 示例 `alert-dialog-small-media`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/alert-dialog


## Destructive

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


> 示例 `alert-dialog-destructive`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/alert-dialog


## RTL

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


> 示例 `alert-dialog-rtl`: 交互预览见 https://jiguang132.com/zh/systems/jguang-ui/docs/components/radix/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 [Radix UI documentation](https://www.radix-ui.com/primitives/docs/components/alert-dialog#api-reference).

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
