確認ダイアログAlertDialogExperimental
削除や破棄など、重要な操作の前に明示的な確認を求めるモーダルダイアログです。
プレビュー
状態とバリエーション
プロパティ
表は横にスクロールできます
| プロパティ | 型 | 初期値 | 説明 |
|---|---|---|---|
| open | boolean | - | 開閉状態を外部で制御します。 |
| onOpenChange | (open: boolean) => void | - | 開閉状態が変わった時に呼び出されます。 |
| portalContainer | HTMLElement | null | - | プレビュー枠や疑似ブラウザ内に閉じ込めたい場合のポータル先です。 |
使い方
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
Button,
buttonVariants,
cn,
} from "@gunjo/ui";
import { IconTrash as Trash2 } from "@tabler/icons-react";
export function DeleteProjectDialog() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive" className="gap-2">
<Trash2 className="h-4 w-4" />
プロジェクトを削除
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>このプロジェクトを削除しますか?</AlertDialogTitle>
<AlertDialogDescription>
関連するタスク、ファイル、共有リンクも削除されます。この操作は取り消せません。
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>キャンセル</AlertDialogCancel>
<AlertDialogAction className={cn(buttonVariants({ variant: "destructive" }))}>
削除
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}設計の判断(UIXHERO)
「いつ・なぜ使うか」の判断は、姉妹サイト UIXHERO の記事で解説しています。