react-confirm-lite 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,151 +1,243 @@
1
- # react-confirm-lite
2
-
3
- **A lightweight, promise-based confirm dialog for React with built-in styling**
4
-
5
- ✨ **Features:**
6
- - Promise-based API like window.confirm
7
- - Built-in styling with multiple color schemes
8
- - Zero dependencies
9
- - Fully customizable
10
- - TypeScript support
11
- - Queue system for multiple dialogs
12
- - Works with Next.js App Router (no 'use client' needed)
13
- - Automatic CSS injection (no separate imports needed)
14
- ---
15
-
16
- ## Recommendations
17
- - Always use the latest version for bug fixes and improvements
18
- - If you face any issues, please report them on [GitHub](https://github.com/SaadNasir-git/react-confirm-lite/issues)
19
-
20
- ![react-confirm-lite sample](https://res.cloudinary.com/dhcqn5bmq/image/upload/v1766778602/Screencastfrom2025-12-2700-42-14-ezgif.com-optimize_od1ht2.gif)
1
+ # React Confirm Lite ✨
21
2
 
22
- ## Quick Comparison
3
+ **A lightweight, promise-based confirm dialog for React, designed to be as easy to use as react-toastify, while remaining fully customizable.**
23
4
 
24
- | Feature | react-confirm-lite | react-confirm | react-confirm-toast |
25
- |---------|-------------------|---------------|---------------------|
26
- | Built-in styling | ✅ Multiple color schemes | ❌ None | ✅ Toast style |
27
- | Promise-based | ✅ | ✅ | ✅ |
28
- | Zero dependencies | ✅ | ✅ | ✅ |
29
- | Queue system | ✅ | ❌ | ❌ |
30
- | Automatic CSS | ✅ No separate imports | ❌ | ❌ |
31
- | Next.js App Router | ✅ Works out of the box | ❌ Needs 'use client' | ✅ |
5
+ [![npm version](https://img.shields.io/npm/v/react-confirm-lite)](https://www.npmjs.com/package/react-confirm-lite)
6
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/react-confirm-lite)](https://bundlephobia.com/package/react-confirm-lite)
7
+ [![npm downloads](https://img.shields.io/npm/dm/react-confirm-lite)](https://www.npmjs.com/package/react-confirm-lite)
8
+ [![license](https://img.shields.io/npm/l/react-confirm-lite)](https://github.com/SaadNasir-git/react-confirm-lite/blob/main/LICENSE)
9
+ [![typescript](https://img.shields.io/badge/types-TypeScript-blue)](https://www.typescriptlang.org/)
10
+ [![react](https://img.shields.io/badge/react-%3E%3D18-blue)](https://reactjs.org/)
32
11
 
33
- ## Why Choose react-confirm-lite?
34
-
35
- If you want a **simple, lightweight** confirm dialog that **just works** without any configuration, `react-confirm-lite` is perfect. No separate CSS imports, no 'use client' directives needed in Next.js App Router, and fully customizable when you need it.
12
+ ![Sample Image](https://camo.githubusercontent.com/af08928ac7006e57dc2a28f01b1fbc7214ea742379365f364f37bb204a93906b/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f646863716e35626d712f696d6167652f75706c6f61642f76313736363737383630322f53637265656e6361737466726f6d323032352d31322d323730302d34322d31342d657a6769662e636f6d2d6f7074696d697a655f6f64316874322e676966)
36
13
 
37
14
  ## 🔗 Live Demo
38
15
 
39
16
  [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/vitejs-vite-bfthlpmw?file=src%2FApp.tsx)
40
17
 
41
- ## Getting Started
18
+ ## 📦 Installation
42
19
 
43
- ### Step 1: **Install the package**:
44
20
  ```bash
45
21
  npm install react-confirm-lite
22
+ # or
23
+ yarn add react-confirm-lite
24
+ # or
25
+ pnpm add react-confirm-lite
46
26
  ```
47
27
 
48
- ### Step 2: Import in your component:
28
+ ## 🚀 Quick Start
29
+
30
+ ### 1. Add the Container Component
31
+
32
+ Place `<ConfirmContainer />` in your app (usually in root layout):
33
+
49
34
  ```tsx
50
- import { confirm, ConfirmContainer } from 'react-confirm-lite';
51
- ```
35
+ import { ConfirmContainer } from 'react-confirm-lite';
52
36
 
53
- ### Step 3: Add ConfirmContainer to your component tree:
54
- ```jsx
55
37
  function App() {
56
38
  return (
57
- <>
58
- <ConfirmContainer />
39
+ <div>
59
40
  {/* Your app content */}
60
- </>
41
+ <ConfirmContainer />
42
+ </div>
61
43
  );
62
44
  }
63
45
  ```
64
46
 
65
- ### Step 4: Use the confirm function:
47
+ ### 2. Use the Confirm Function
48
+
49
+ Import and use `confirm()` anywhere in your app:
50
+
66
51
  ```tsx
67
- const handleAction = async () => {
68
- const isConfirmed = await confirm('Are you sure?');
69
- if (isConfirmed) {
70
- // Perform action
71
- console.log('Confirmed!');
52
+ import { confirm } from 'react-confirm-lite';
53
+
54
+ async function handleAction() {
55
+ const result = await confirm('Are you sure?');
56
+
57
+ if (result) {
58
+ console.log('User confirmed!');
59
+ } else {
60
+ console.log('User cancelled!');
72
61
  }
73
- };
62
+ }
74
63
  ```
75
64
 
76
- ### Complete Example:
65
+ ## 🎯 Features
77
66
 
67
+ ### ✅ Simple Promise-based API
78
68
  ```tsx
79
- import { confirm, ConfirmContainer } from 'react-confirm-lite';
69
+ const result = await confirm('Message here');
70
+ // Returns true for OK, false for Cancel, null for ESC/outside click
71
+ ```
80
72
 
81
- function App() {
82
- const handleDelete = async () => {
83
- const isConfirmed = await confirm('Are you sure you want to delete this item?');
84
- if (isConfirmed) {
85
- // Delete logic here
86
- console.log('Item deleted');
87
- }
88
- };
73
+ ### 18 Built-in Animations
74
+ Choose from various animations:
75
+ - `slide` (default) - Smooth slide up/down
76
+ - `fadeScale` - Fade with scale effect
77
+ - `bounce` - Playful bounce animation
78
+ - `flip` - 3D flip effect
79
+ - `zoom` - Zoom in/out
80
+ - `rotate` - Rotate animation
81
+ - `fadeUp` / `fadeDown` - Directional fade
82
+ - `drop` - 3D drop effect
83
+ - `slideRight` / `slideLeft` - Horizontal slides
84
+ - `slideVertical` - Vertical slide
85
+ - `slideDown` - Slide down
86
+ - `rotateRight` - Rotate from right
87
+ - `zoomSmall` / `bounceSmall` - Subtle animations
88
+ - `fadeBlur` / `fadeShrink` - Creative effects
89
+
90
+ ### ✅ 6 Color Schemes
91
+ Pre-built color themes:
92
+ - `dark` (default) - Dark theme
93
+ - `light` - Light theme
94
+ - `blue` - Blue theme
95
+ - `red` - Perfect for destructive actions
96
+ - `green` - Success actions
97
+ - `purple` - Premium/feature actions
98
+
99
+ ### ✅ Interactive Controls
100
+ - `closeOnEscape` (default: true) - Press ESC to close
101
+ - `closeOnClickOutside` (default: true) - Click backdrop to close
102
+ - Returns `null` when closed via ESC or backdrop click
103
+
104
+ ### ✅ Customizable Options
105
+ Control every aspect:
106
+ - Custom OK/Cancel button text
107
+ - Separate animation durations for enter/exit
108
+ - Override colors per dialog
109
+ - Custom CSS classes for all elements
110
+
111
+ ### ✅ Queue System
112
+ Multiple confirm requests automatically queue and show one at a time:
113
+ ```tsx
114
+ // These will show sequentially
115
+ await confirm('First?');
116
+ await confirm('Second?');
117
+ await confirm('Third?');
118
+ ```
89
119
 
90
- return (
91
- <div>
92
- <button onClick={handleDelete}>Delete Item</button>
93
- <ConfirmContainer />
94
- </div>
95
- );
120
+ ### ✅ Zero Configuration
121
+ No CSS imports needed. Styles are automatically injected.
122
+
123
+ ## 🎨 Usage Examples
124
+
125
+ ### Basic Usage
126
+ ```tsx
127
+ const result = await confirm('Delete this item?');
128
+ if (result) {
129
+ // User clicked OK
130
+ deleteItem();
131
+ } else if (result === false) {
132
+ // User clicked Cancel
133
+ console.log('Cancelled');
134
+ } else if (result === null) {
135
+ // User pressed ESC or clicked outside
136
+ console.log('Closed via ESC/backdrop');
96
137
  }
97
138
  ```
98
139
 
99
- ## Advanced Usage
140
+ ### Custom Dialog Options
141
+ ```tsx
142
+ const result = await confirm({
143
+ title: 'Delete Account',
144
+ message: 'This will permanently delete your account and all data.',
145
+ okText: 'Delete Forever',
146
+ cancelText: 'Cancel',
147
+ colorSchema: 'red'
148
+ });
149
+ ```
100
150
 
101
- ### Custom Options:
151
+ ### Disable ESC and Backdrop Closing
102
152
  ```tsx
103
- const handleCustomConfirm = async () => {
104
- const isConfirmed = await confirm({
105
- title: "Delete Item",
106
- message: "This action cannot be undone. Are you sure?",
107
- cancelText: 'No, keep it',
108
- okText: 'Yes, delete',
109
- colorSchema: 'red',
110
- isDestructive: true
111
- });
112
-
113
- if (isConfirmed) {
114
- // Delete item
115
- }
116
- };
153
+ <ConfirmContainer
154
+ closeOnEscape={false}
155
+ closeOnClickOutside={false}
156
+ />
157
+ // Now dialog can only be closed with Cancel/OK buttons
117
158
  ```
118
159
 
119
- ### Custom Color Scheme:
120
- ```jsx
121
- <ConfirmContainer defaultColorSchema="light" />
122
- // Available options: 'light', 'dark', 'blue', 'red', 'green', 'purple'
160
+ ## 🔧 API Reference
161
+
162
+ ### Confirm Container Props
163
+
164
+ | Prop | Type | Default | Description |
165
+ |------|------|---------|-------------|
166
+ | `animation` | `AnimationType` | `'slide'` | Animation type (18 options) |
167
+ | `animationDuration` | `number` | `300` | Base animation duration (ms) |
168
+ | `animationDurationIn` | `number` | - | Enter animation duration |
169
+ | `animationDurationOut` | `number` | - | Exit animation duration |
170
+ | `defaultColorSchema` | `ColorSchema` | `'dark'` | Default color scheme |
171
+ | `closeOnEscape` | `boolean` | `true` | Close with ESC key |
172
+ | `closeOnClickOutside` | `boolean` | `true` | Close on backdrop click |
173
+ | `classes` | `ConfirmClasses` | `{}` | Custom CSS classes |
174
+
175
+ ### Confirm Function
176
+
177
+ ```tsx
178
+ // String input (simple)
179
+ await confirm('Simple message');
180
+
181
+ // Object input (full options)
182
+ await confirm({
183
+ title: 'Custom Title', // Optional
184
+ message: 'Required message', // Required
185
+ okText: 'Proceed', // Optional
186
+ cancelText: 'Go Back', // Optional
187
+ colorSchema: 'blue', // Optional
188
+ });
123
189
  ```
124
190
 
125
- ### Custom Styling:
126
- ```jsx
191
+ **Return values:**
192
+ - `true` - User clicked OK
193
+ - `false` - User clicked Cancel
194
+ - `null` - User pressed ESC or clicked outside (if enabled)
195
+
196
+ ### Custom Styling with CSS Classes
197
+
198
+ ```tsx
127
199
  <ConfirmContainer
128
200
  classes={{
129
- overlay: "bg-black/50",
130
- wrapper: "rounded-xl shadow-2xl",
131
- title: "text-2xl font-bold",
132
- message: "text-gray-600",
133
- button: "px-6 py-3 rounded-lg font-medium",
134
- cancel: "border border-gray-300 hover:bg-gray-50",
135
- ok: "bg-blue-600 hover:bg-blue-700 text-white"
201
+ overlay: "my-overlay-class", // Background overlay
202
+ wrapper: "my-modal-class", // Modal container
203
+ title: "my-title-class", // Title text
204
+ message: "my-message-class", // Message text
205
+ button: "my-button-class", // Both buttons
206
+ cancel: "my-cancel-class", // Cancel button only
207
+ ok: "my-ok-class", // OK button only
136
208
  }}
137
209
  />
138
210
  ```
139
211
 
140
- ### Fully Custom UI with Render Prop:
141
- ```jsx
212
+ ## 🎭 Custom UI with Render Prop
213
+
214
+ Want complete control over the UI? Use the render prop:
215
+
216
+ ```tsx
142
217
  <ConfirmContainer animationDuration={500}>
143
- {({ isVisible, confirm, handleCancel, handleOk }) => (
144
- <div className={`modal ${isVisible ? 'show' : 'hide'}`}>
145
- <div className="modal-content">
218
+ {({
219
+ isVisible,
220
+ confirm,
221
+ handleCancel,
222
+ handleOk,
223
+ containerRef,
224
+ animationClass,
225
+ animationStyle
226
+ }) => (
227
+ <div className={`modal-overlay ${isVisible ? 'show' : 'hide'}`}>
228
+ {/* Your custom backdrop */}
229
+ <div className="backdrop" onClick={handleCancel} />
230
+
231
+ {/* Your custom modal */}
232
+ <div
233
+ ref={containerRef}
234
+ className={`custom-modal ${animationClass}`}
235
+ style={animationStyle}
236
+ >
146
237
  <h2>{confirm.title}</h2>
147
238
  <p>{confirm.message}</p>
148
- <div className="modal-actions">
239
+
240
+ <div className="buttons">
149
241
  <button onClick={handleCancel}>
150
242
  {confirm.cancelText || 'Cancel'}
151
243
  </button>
@@ -159,222 +251,238 @@ const handleCustomConfirm = async () => {
159
251
  </ConfirmContainer>
160
252
  ```
161
253
 
162
- ## Next.js App Router Support
254
+ **Available render props:**
255
+ - `isVisible`: Boolean indicating if dialog should be visible
256
+ - `confirm`: The current confirm options object
257
+ - `handleCancel`: Function to cancel the dialog (returns false)
258
+ - `handleOk`: Function to confirm the dialog (returns true)
259
+ - `containerRef`: React ref for the modal container
260
+ - `colorSchema`: Current color scheme
261
+ - `animationClass`: CSS class for current animation
262
+ - `animationStyle`: Style object with animation duration
163
263
 
164
- Works automatically! No 'use client' directive needed for the library. The library handles everything internally.
264
+ ## 📱 Real-World Examples
165
265
 
166
- ### Server Components Example:
266
+ ### Delete Confirmation with ESC Disabled
167
267
  ```tsx
168
- // app/layout.tsx
169
- import { ConfirmContainer } from 'react-confirm-lite';
268
+ const handleDelete = async () => {
269
+ // Force user to make explicit choice
270
+ const result = await confirm({
271
+ title: 'Delete Item',
272
+ message: 'This action cannot be undone. Are you sure?',
273
+ okText: 'Delete',
274
+ cancelText: 'Keep',
275
+ colorSchema: 'red'
276
+ });
170
277
 
171
- export default function RootLayout({
172
- children,
173
- }: {
174
- children: React.ReactNode;
175
- }) {
176
- return (
177
- <html lang="en">
178
- <body>
179
- {children}
180
- <ConfirmContainer />
181
- </body>
182
- </html>
183
- );
184
- }
185
- ```
186
- ```tsx
187
- // app/page.tsx (server component)
188
- import { confirm } from 'react-confirm-lite';
278
+ // Result can only be true or false (no null since ESC/backdrop disabled)
279
+ if (result) {
280
+ await deleteItem();
281
+ }
282
+ };
189
283
 
190
- export default async function Page() {
191
- // Server-side logic here
192
-
193
- return (
194
- <form action={async () => {
195
- 'use server';
196
- const isConfirmed = await confirm('Are you sure?');
197
- if (isConfirmed) {
198
- // Server action
199
- }
200
- }}>
201
- <button>Submit</button>
202
- </form>
203
- );
204
- }
284
+ // In your component
285
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={false} />
205
286
  ```
206
287
 
207
- ### Client Component Example:
288
+ ### Form Submission with Backdrop Only
208
289
  ```tsx
209
- 'use client';
210
- import { confirm, ConfirmContainer } from 'react-confirm-lite';
211
-
212
- export default function ClientComponent() {
213
- const handleClick = async () => {
214
- const result = await confirm('Confirm action?');
215
- if (result) {
216
- // Handle confirmation
217
- }
218
- };
290
+ // Allow closing by clicking backdrop but not ESC
291
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={true} />
292
+
293
+ const handleSubmit = async () => {
294
+ const result = await confirm({
295
+ title: 'Submit Form',
296
+ message: 'Ready to submit this form?',
297
+ okText: 'Submit',
298
+ cancelText: 'Review',
299
+ colorSchema: 'green'
300
+ });
219
301
 
220
- return (
221
- <div>
222
- <button onClick={handleClick}>Click me</button>
223
- <ConfirmContainer />
224
- </div>
225
- );
226
- }
302
+ if (result) {
303
+ await submitForm();
304
+ } else if (result === null) {
305
+ // User clicked backdrop
306
+ console.log('Closed by clicking outside');
307
+ }
308
+ };
227
309
  ```
228
310
 
229
- ## API Reference
311
+ ### Different Behaviors for Different Dialogs
312
+ ```tsx
313
+ // Global: ESC and backdrop disabled
314
+ <ConfirmContainer
315
+ closeOnEscape={false}
316
+ closeOnClickOutside={false}
317
+ />
230
318
 
231
- ### `confirm(message: string | ConfirmOptions): Promise<boolean>`
319
+ // Some dialogs can override via custom UI
320
+ const handleFlexibleDialog = async () => {
321
+ // Create custom UI that allows ESC/backdrop
322
+ const result = await confirm('Flexible dialog?');
323
+ // result can be true, false, or null
324
+ };
325
+ ```
232
326
 
233
- Displays a confirmation dialog. Returns a promise that resolves to `true` if confirmed, `false` if cancelled.
327
+ ## 🏗️ Container Configuration
234
328
 
235
- **String usage:**
236
- ```ts
237
- await confirm('Simple message');
238
- // Equivalent to: { title: 'Confirm', message: 'Simple message' }
329
+ ### Global Settings
330
+ ```tsx
331
+ <ConfirmContainer
332
+ defaultColorSchema="light" // Light theme by default
333
+ animation="zoom" // Zoom animation for all dialogs
334
+ animationDuration={400} // 400ms animations
335
+ closeOnEscape={true} // Allow ESC to close
336
+ closeOnClickOutside={true} // Allow backdrop click to close
337
+ animationDurationIn={350} // Enter: 350ms
338
+ animationDurationOut={250} // Exit: 250ms
339
+ />
239
340
  ```
240
341
 
241
- **Object usage:**
242
- ```ts
243
- await confirm({
244
- title: 'Warning',
245
- message: 'This action cannot be undone',
246
- cancelText: 'Cancel',
247
- okText: 'Delete',
248
- colorSchema: 'red',
249
- isDestructive: true
250
- });
251
- ```
342
+ ### Different Close Behaviors
343
+ ```tsx
344
+ // Option 1: Fully closable (default)
345
+ <ConfirmContainer closeOnEscape={true} closeOnClickOutside={true} />
346
+ // Users can close via: OK, Cancel, ESC, or backdrop click
252
347
 
253
- ### `ConfirmContainer` Props:
348
+ // Option 2: Force explicit choice
349
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={false} />
350
+ // Users can only close via: OK or Cancel buttons
254
351
 
255
- | Prop | Type | Default | Description |
256
- |------|------|---------|-------------|
257
- | `defaultColorSchema` | `ColorSchema` | `'dark'` | Default color scheme |
258
- | `animationDuration` | `number` | `300` | Animation duration in ms |
259
- | `classes` | `ConfirmClasses` | `{}` | Custom CSS classes |
260
- | `children` | Render function | - | For complete UI customization |
261
-
262
- ### Types:
263
- ```ts
264
- type ColorSchema = 'light' | 'dark' | 'blue' | 'red' | 'green' | 'purple';
265
-
266
- interface ConfirmClasses {
267
- overlay?: string;
268
- wrapper?: string;
269
- title?: string;
270
- message?: string;
271
- button?: string;
272
- cancel?: string;
273
- ok?: string;
274
- }
352
+ // Option 3: Backdrop only
353
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={true} />
354
+ // Users can close via: OK, Cancel, or backdrop click
275
355
 
276
- interface ConfirmOptions {
277
- title?: string;
278
- message: string;
279
- cancelText?: string;
280
- okText?: string;
281
- colorSchema?: ColorSchema;
282
- isDestructive?: boolean;
283
- }
356
+ // Option 4: ESC only
357
+ <ConfirmContainer closeOnEscape={true} closeOnClickOutside={false} />
358
+ // Users can close via: OK, Cancel, or ESC key
284
359
  ```
285
360
 
286
- ## Troubleshooting
361
+ ## 🎨 Animation Gallery
287
362
 
288
- ### Dialog not appearing?
289
- - Make sure `<ConfirmContainer />` is rendered in your component tree
290
- - Check that you're not conditionally rendering it in a way that unmounts it
363
+ ### Slide Animations
364
+ - `slide` - Smooth vertical slide (default)
365
+ - `slideRight` / `slideLeft` - Horizontal slides
366
+ - `slideVertical` - Vertical slide
367
+ - `slideDown` - Slide down
291
368
 
292
- ### Multiple dialogs overlapping?
293
- - The library has a built-in queue system that handles multiple confirm requests sequentially
369
+ ### Fade Animations
370
+ - `fadeScale` - Fade with scaling
371
+ - `fadeUp` / `fadeDown` - Directional fades
372
+ - `fadeBlur` - Fade with blur effect
373
+ - `fadeShrink` - Fade with shrink effect
294
374
 
295
- ### Styling not working?
296
- - If using custom classes, ensure they have proper CSS specificity
297
- - Try using `!important` flag for custom styles if needed
298
- - Make sure you're on the latest version
375
+ ### 3D Animations
376
+ - `flip` - Card flip effect
377
+ - `drop` - 3D drop animation
378
+ - `rotate` / `rotateRight` - Rotation effects
299
379
 
300
- ### Animation issues with custom UI?
301
- - When using the `children` render prop, use the `isVisible` prop for animations
302
- - Set appropriate `animationDuration` to match your CSS transitions
380
+ ### Playful Animations
381
+ - `bounce` / `bounceSmall` - Bounce effects
382
+ - `zoom` / `zoomSmall` - Zoom in/out
303
383
 
304
- ### Next.js hydration errors?
305
- - The library is designed to work with Next.js App Router
306
- - If using in a layout, ensure it's placed after dynamic content
384
+ ## 🚨 Troubleshooting
307
385
 
308
- ## Features in Detail
386
+ ### Dialog not showing?
387
+ - Make sure `<ConfirmContainer />` is mounted
388
+ - Check it's not conditionally rendered
309
389
 
310
- ### 🎨 Multiple Color Schemes
311
- Six built-in color schemes: light, dark, blue, red, green, purple. Set globally or per confirm dialog.
390
+ ### ESC key not working?
391
+ - Check if `closeOnEscape={true}` (default)
392
+ - Ensure no other event is preventing ESC
393
+ - Try different browsers
312
394
 
313
- ### 🔄 Queue System
314
- Multiple confirm requests are queued and shown one at a time, preventing overlapping dialogs.
395
+ ### Backdrop click not working?
396
+ - Verify `closeOnClickOutside={true}` (default)
397
+ - Check if any parent element is preventing clicks
315
398
 
316
- ### 🎯 Zero Configuration
317
- Works out of the box with default styling. No CSS imports needed.
399
+ ### Animation not working?
400
+ - Verify animation name is correct
401
+ - Check browser console for errors
318
402
 
319
- ### 🔧 Fully Customizable
320
- From simple class overrides to complete UI replacement with render props.
403
+ ### TypeScript errors?
404
+ - Ensure you have `@types/react` installed
405
+ - Update to latest TypeScript version
321
406
 
322
- ### 📱 Responsive Design
323
- Built-in responsive styling that works on all screen sizes.
407
+ ### Styling issues?
408
+ - Use `classes` prop to override styles
409
+ - Check CSS specificity
324
410
 
325
- ### 🔒 Type Safety
326
- Full TypeScript support with comprehensive type definitions.
411
+ ## 📱 Next.js Support
327
412
 
328
- ## Performance
329
-
330
- - **Zero dependencies**: Only React as a peer dependency
331
- - **Tree-shakeable**: Only imports what you use
332
- - **Small bundle size**: ~5KB gzipped (including styles)
333
- - **Optimized renders**: Minimal re-renders with React.memo
413
+ ### App Router (Next.js 15+)
414
+ ```tsx
415
+ // app/layout.tsx
416
+ import { ConfirmContainer } from 'react-confirm-lite';
334
417
 
335
- ## Migration from Older Versions
418
+ export default function RootLayout({
419
+ children,
420
+ }: {
421
+ children: React.ReactNode;
422
+ }) {
423
+ return (
424
+ <html lang="en">
425
+ <body>
426
+ {children}
427
+ <ConfirmContainer />
428
+ </body>
429
+ </html>
430
+ );
431
+ }
432
+ ```
336
433
 
337
- If you're upgrading from version <1.3.0:
434
+ ### Server Components
435
+ ```tsx
436
+ // Server actions
437
+ 'use server';
438
+ import { confirm } from 'react-confirm-lite';
338
439
 
339
- 1. **'use client' not needed**: The library handles this internally
340
- 2. **Simpler API**: Same functions, better internals
440
+ export async function serverAction() {
441
+ const result = await confirm('Confirm from server?');
442
+ if (result) {
443
+ // Perform action
444
+ } else if (result === null) {
445
+ // User pressed ESC or clicked outside
446
+ console.log('Action cancelled');
447
+ }
448
+ }
449
+ ```
341
450
 
451
+ ## 🔄 Migration from Other Libraries
342
452
 
343
- ## Contributing
453
+ ### From window.confirm()
454
+ ```tsx
455
+ // Old way (always returns true/false)
456
+ if (window.confirm('Delete?')) {
457
+ deleteItem();
458
+ }
344
459
 
345
- Contributions are welcome! Please:
460
+ // New way (returns true/false/null)
461
+ const result = await confirm('Delete?');
462
+ if (result === true) {
463
+ await deleteItem();
464
+ } else if (result === false) {
465
+ console.log('User clicked Cancel');
466
+ } else if (result === null) {
467
+ console.log('User pressed ESC');
468
+ }
469
+ ```
346
470
 
347
- 1. Fork the repository
348
- 2. Create a feature branch
349
- 3. Add tests for your changes
350
- 4. Submit a pull request
471
+ ### From Other Confirm Libraries
472
+ - No CSS imports needed
473
+ - Automatic queue system
474
+ - Built-in animations
475
+ - Zero configuration
476
+ - Three return states (true/false/null)
351
477
 
352
- ## Author
478
+ ## 📄 License
353
479
 
354
- **Saad Nasir** - Full Stack Developer
355
- - GitHub: [@SaadNasir-git](https://github.com/SaadNasir-git)
356
- - For support: Open an issue on GitHub
480
+ MIT License - free for personal and commercial use.
357
481
 
358
- ## License
482
+ ## 👨‍💻 Author
359
483
 
360
- MIT © Saad Nasir
484
+ **Saad Nasir** - Creator of react-confirm-lite
361
485
 
362
486
  ---
363
487
 
364
- ![npm version](https://img.shields.io/npm/v/react-confirm-lite)
365
- ![bundle size](https://img.shields.io/bundlephobia/minzip/react-confirm-lite)
366
- ![npm downloads](https://img.shields.io/npm/dm/react-confirm-lite)
367
- ![license](https://img.shields.io/npm/l/react-confirm-lite)
368
- ![typescript](https://img.shields.io/badge/types-TypeScript-blue)
369
- ![react](https://img.shields.io/badge/react-%3E%3D18-blue)
370
- ![next.js](https://img.shields.io/badge/next.js-15+-black)
371
-
372
- ## Support
373
-
374
- If you find this library helpful, please consider:
375
- - ⭐ Starring the repository on GitHub
376
- - 📢 Sharing with your network
377
- - 🐛 Reporting issues you encounter
378
- - 💡 Suggesting new features
379
-
380
- Happy coding! 🚀
488
+ **Found this useful? Give it a star on GitHub!** ⭐