Components
Self-contained confirm dialog component with loading and destructive variant
Loading preview...
"use client";
import { useState } from "react";
import ConfirmDialog from "@/components/ui/confirmdialog";
export default function ConfirmDialogDemo() {
const [open, setOpen] = useState(false);
return (
<>
<button
className="inline-flex h-9 items-center justify-center rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground shadow hover:bg-destructive/90"
onClick={() => setOpen(true)}
>
Excluir item
</button>
<ConfirmDialog
open={open}
onOpenChange={setOpen}
title="Confirmar exclusão"
description="Esta ação não pode ser desfeita. Deseja continuar?"
confirmLabel="Excluir"
cancelLabel="Cancelar"
variant="destructive"
onConfirm={() => setOpen(false)}
/>
</>
);
}