# ConfirmModal

**When to use:** Confirmation dialog before destructive or irreversible actions — delete, archive, send, overwrite.

**Keywords:** are you sure

**Import:** `import { ConfirmModal } from '@ahrowe/ui'`

```tsx
import { ConfirmModal } from '@ahrowe/ui';

const [isOpen, setIsOpen] = useState(false);

<button onClick={() => setIsOpen(true)}>Delete</button>

<ConfirmModal
  isOpen={isOpen}
  title="Delete item?"
  content="This action cannot be undone."
  onConfirm={async () => {
    await deleteItem();
  }}
  onClose={(didSubmit) => {
    setIsOpen(false);
    // didSubmit is true if user clicked confirm, false if cancelled
  }}
/>
```

**Key props:**

| Prop | Type | Description |
|------|------|-------------|
| `isOpen` | `boolean` | Controls visibility |
| `title` | `ReactNode` | Dialog heading |
| `content` | `ReactNode` | Dialog body |
| `onConfirm` | `() => void \| Promise<void>` | Called when user confirms |
| `onClose` | `(didSubmit: boolean) => void` | Called on both confirm and cancel |
| `labels.submit` | `string` | Confirm button label (default `'Confirm'`) |
| `isDelete` | `boolean` | Render the confirm button with the destructive (delete) style |
| `actionButtonsProps` | `ActionButtonsProps` | Overrides passed through to the underlying `ActionButtons` (wins over `labels.submit` / `isDelete`) |
| `children` | `ReactNode` | Alternative to `content` prop |

**Destructive action:**

```tsx
<ConfirmModal
  isOpen={isOpen}
  title="Delete item?"
  content="This action cannot be undone."
  isDelete
  labels={{ submit: 'Delete' }}
  onConfirm={async () => { await deleteItem(); }}
  onClose={() => setIsOpen(false)}
/>
```

**Global defaults:** `ConfirmModal` supports `ConfigProvider` — set a default `labels.submit` (or any other prop) app-wide:

```tsx
<ConfigProvider defaultProps={{ ConfirmModal: { labels: { submit: 'OK' } } }}>
  <App />
</ConfigProvider>
```

**Labels:** `submit` `cancel` — the text this component renders of its own. Pass `labels` to override any of them, on the component or app-wide through `ConfigProvider`; keys merge individually. Type: `ConfirmModalLabels`.
