컴포넌트
Alert Dialog
되돌릴 수 없는 행동을 확인한다. 첫 포커스는 취소.
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@zest/primitives/AlertDialog.js'
import { Button } from '@zest/primitives/Button.js'
export default function Demo() {
return (
<AlertDialog>
<AlertDialogTrigger asChild><Button variant="danger">퇴사 확정</Button></AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>퇴사를 확정할까요?</AlertDialogTitle>
<AlertDialogDescription>확정하면 모든 알림이 멈추고 되돌릴 수 없어요.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>취소</AlertDialogCancel>
<AlertDialogAction destructive>퇴사 확정</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}설치
shadcn CLI 로 소스를 프로젝트에 가져와요. 테마·유틸·의존 부품이 함께 설치돼요.
npx shadcn@latest add @zest/alert-dialog패키지로 쓰려면 @zest-im/ui 에서 가져와요. 설치 안내
사용법
import { AlertDialogAction } from '@/components/ui/alert-dialog'위 미리보기의 「코드」 탭이 실제로 동작하는 예제예요.
API
| prop | 타입 | 설명 |
|---|---|---|
destructive? | boolean | — |
표에 없는 HTML·Radix 속성은 그대로 전달돼요.
접근성
바깥 클릭으로 닫히지 않고, 열리면 취소 버튼에 포커스가 간다.