Skip to content

Alert Dialog

新粗野主义风格的确认对话框,需要用户交互。基于 reka-ui 的 AlertDialog 原语构建。

预览

安装

pnpm dlx brutx@latest add alert-dialog

用法

vue
<script setup>
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from '@/components/ui'
import Button from '@/components/ui/Button.vue'
</script>

<template>
    <AlertDialog>
        <AlertDialogTrigger as-child>
            <Button variant="danger">Delete Account</Button>
        </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.
                </AlertDialogDescription>
            </AlertDialogHeader>
            <AlertDialogFooter>
                <AlertDialogCancel>Cancel</AlertDialogCancel>
                <AlertDialogAction>Continue</AlertDialogAction>
            </AlertDialogFooter>
        </AlertDialogContent>
    </AlertDialog>
</template>

子组件

组件说明
AlertDialog根组件(从 reka-ui 的 AlertDialogRoot 重新导出)
AlertDialogTrigger打开对话框的按钮
AlertDialogContent对话框内容面板
AlertDialogHeader标题和描述的头部容器
AlertDialogFooter操作按钮的底部容器
AlertDialogTitle对话框标题
AlertDialogDescription对话框描述文本
AlertDialogAction确认操作按钮
AlertDialogCancel关闭对话框的取消按钮

Props

AlertDialogContent

属性类型默认值
showCloseButtonbooleantrue
classstring

AlertDialogAction / AlertDialogCancel

属性类型默认值
classstring

无障碍

  • 对话框打开时,焦点被限制在对话框内
  • Escape 关闭对话框
  • AlertDialogCancel 点击后关闭对话框
  • AlertDialogAction 确认并关闭对话框