Components
AlertDialog
알림 다이얼로그 컴포넌트
AlertDialog
알림 다이얼로그는 사용자 확인이 필요한 작업에 사용하는 모달 대화 상자입니다.
기본 사용법
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel,} from '@aift/ui/AlertDialog';export default function Preview() { return ( <AlertDialog> <AlertDialogTrigger>열기</AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>알림</AlertDialogTitle> <AlertDialogDescription> 이 작업을 진행하시겠습니까? </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>취소</AlertDialogCancel> <AlertDialogAction>확인</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> );}Status
확인 버튼의 status prop으로 버튼 색상을 지정할 수 있습니다.
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, AlertDialogStatusIcon, type AlertDialogStatus,} from '@aift/ui/AlertDialog';import { Button } from '@aift/ui/Button';function AlertDialogStatusExample({ status, triggerLabel, actionLabel = '확인',}: { status: AlertDialogStatus; triggerLabel: string; actionLabel?: string;}) { return ( <AlertDialog> <AlertDialogTrigger asChild> <Button variant="outlined">{triggerLabel}</Button> </AlertDialogTrigger> <AlertDialogContent> <div className="flex w-full flex-col items-center gap-4"> <div className="flex w-full flex-col items-center gap-3"> <AlertDialogStatusIcon status={status} /> <AlertDialogTitle>{triggerLabel}</AlertDialogTitle> </div> <AlertDialogDescription> Figma Alert Type 1 — {triggerLabel} 상태 예시입니다. </AlertDialogDescription> </div> <AlertDialogFooter> <AlertDialogCancel>취소</AlertDialogCancel> <AlertDialogAction status={status}>{actionLabel}</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> );}export default function Status() { return ( <div className="flex flex-wrap gap-2"> <AlertDialogStatusExample status="primary" triggerLabel="Primary" /> <AlertDialogStatusExample status="info" triggerLabel="Info" /> <AlertDialogStatusExample status="success" triggerLabel="Success" /> <AlertDialogStatusExample status="caution" triggerLabel="Caution" /> <AlertDialogStatusExample status="error" triggerLabel="Error" actionLabel="삭제" /> </div> );}Props
AlertDialog는 Radix UI의 Alert Dialog를 기반으로 하며, 여러 하위 컴포넌트로 구성됩니다.
AlertDialog: 루트 컴포넌트AlertDialogTrigger: 다이얼로그를 여는 트리거AlertDialogContent: 다이얼로그 콘텐츠AlertDialogHeader: 헤더 영역AlertDialogTitle: 제목AlertDialogDescription: 설명AlertDialogFooter: 푸터 영역AlertDialogAction: 확인 버튼 (status:'primary' \| 'secondary' \| 'info' \| 'error' \| 'caution' \| 'success')AlertDialogCancel: 취소 버튼