Components/ConfirmDialog

ConfirmDialog

form

A modal confirmation dialog with customizable title, message, and action buttons. Perfect for destructive actions that need user confirmation.

1Installation

Install the package:

$npm install piece-ui

Import the component:

tsx
1import { ConfirmDialog } from "piece-ui";

2Usage

Basic usage

tsx
1import { useState } from "react";
2import { ConfirmDialog, Button } from "piece-ui";
3
4export default function Example() {
5  const [open, setOpen] = useState(false);
6
7  return (
8    <>
9      <Button variant="danger" onClick={() => setOpen(true)}>
10        Delete Account
11      </Button>
12      <ConfirmDialog
13        open={open}
14        onClose={() => setOpen(false)}
15        onConfirm={() => {
16          console.log("Confirmed!");
17          setOpen(false);
18        }}
19        title="Delete Account"
20        message="This action cannot be undone. All your data will be permanently removed."
21        confirmLabel="Yes, Delete"
22      />
23    </>
24  );
25}

3Props

PropType
openreq
boolean
onClosereq
() => void
onConfirmreq
() => void
title
string
message
string
confirmLabel
string
cancelLabel
string
variant
"danger" | "primary"