# React Confirm Lite ✨
**An async, container-scoped confirmation lite for React with fully customizable dialogs.**
[](https://www.npmjs.com/package/react-confirm-lite)
[](https://bundlephobia.com/package/react-confirm-lite)
[](https://www.npmjs.com/package/react-confirm-lite)
[](https://github.com/SaadNasir-git/react-confirm-lite/blob/main/LICENSE)
[](https://www.typescriptlang.org/)
[](https://reactjs.org/)

## 🚀 Quick Start
### Complete Example
Place `` in your app (usually in root layout) and use it with `confirm`
```tsx
import { ConfirmContainer, confirm } from 'react-confirm-lite';
function App() {
async function handleAction() {
const result = await confirm('Are you sure?');
if (result) {
console.log('User confirmed!');
} else {
console.log('User cancelled!');
}
}
return (
{/* Your app content */}
);
}
```
## Confirm Container Props
| Prop | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| animation | AnimationType | slide | Animation type (16 options) |
| animationDuration | number | 300 | Base animation duration (ms) |
| animationDurationIn | number | - | Enter animation duration |
| animationDurationOut | number | - | Exit animation duration |
| defaultColorScheme | ColorSchema | dark | Default color scheme |
| closeOnEscape | boolean | true | Close with ESC key |
| closeOnClickOutside | boolean | true | Close on backdrop click |
| classes | ConfirmClasses | {} | Custom CSS classes |
## Confirm API options
```tsx
await confirm("Are you sure?");
// OR
await confirm({message:"Are you sure?",title:"Confirm",cancelText:"No",okText:"Yes",colorSchema:"light"})
```
## Custom Dialog
To make custom dialog pass children like this
```tsx
import { confirm, ConfirmContainer } from "react-confirm-manager"
const CustomDialog = () => {
const handleClick = async () => {
const isConfirmed = await confirm('Are you sure?')
if (isConfirmed === null) console.log('User clicked outside or pressed escape')
else if (isConfirmed) console.log('Ok')
else console.log('Cancel')
}
return (
)
}
export default CustomDialog
```
| Prop | Type | Description |
| :--- | :--- | :--- |
| isVisible | boolean | It's value is true when it starts showing and returns false when it starts hiding. It can be used when you made your own custom animation but, if you are using an built in animation then you will not need it. |
| confirm | { id?: string; title?: string; message: string; colorSchema?: ColorSchema; okText?: string; cancelText?: string; }; | It contains the data which you passed through confirm api. |
| containerRef | React.RefObject<HTMLDivElement \| null> | If you want that container hide when you click outside the container then it hides with animation then, you will have to use it mean you will have to give this ref to the container. |
| animationClass | string | It contains the classes for animation. |
| animationStyle | React.CSSProperties | It contains the css properties for animation. |
| handleCancel | () => void | You can give it to the cancle button and you will get false by the confirm api. |
| handleOk | () => void | You can give it to the ok button and you will get true by the confirm api. |