
Alert dialog with validation error state and disabled action.
@shadcnblocks
example/alert-dialog/alert-dialog-form-5.tsx
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
export const title = "Form with Validation State";
const Example = () => (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Transfer</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Transfer Project</AlertDialogTitle>
<AlertDialogDescription>
Type the project name to confirm the transfer.
</AlertDialogDescription>
</AlertDialogHeader>
<div className="space-y-4 py-4">
<div className="space-y-2">
<Label htmlFor="confirm-name">
Project Name: <span className="font-mono">my-project</span>
</Label>
<Input
className="border-destructive focus-visible:ring-destructive"
id="confirm-name"
placeholder="Type project name"
/>
<p className="text-xs text-destructive">
Project name does not match
</p>
</div>
</div>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction className="opacity-50" disabled>
Transfer
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
export default Example;






























