react-confirm-lite 1.2.4 → 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,149 +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
- ## Quick Comparison
1
+ # React Confirm Lite ✨
21
2
 
22
- | Feature | react-confirm-lite | react-confirm | react-confirm-toast |
23
- |---------|-------------------|---------------|---------------------|
24
- | Built-in styling | ✅ Multiple color schemes | ❌ None | ✅ Toast style |
25
- | Promise-based | ✅ | ✅ | ✅ |
26
- | Zero dependencies | ✅ | ✅ | ✅ |
27
- | Queue system | ✅ | ❌ | ❌ |
28
- | Automatic CSS | ✅ No separate imports | ❌ | ❌ |
29
- | Next.js App Router | ✅ Works out of the box | ❌ Needs 'use client' | ✅ |
3
+ **A lightweight, promise-based confirm dialog for React, designed to be as easy to use as react-toastify, while remaining fully customizable.**
30
4
 
31
- ## Why Choose react-confirm-lite?
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
- 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)
34
13
 
35
14
  ## 🔗 Live Demo
36
15
 
37
16
  [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/vitejs-vite-bfthlpmw?file=src%2FApp.tsx)
38
17
 
39
- ## Getting Started
18
+ ## 📦 Installation
40
19
 
41
- ### Step 1: **Install the package**:
42
20
  ```bash
43
21
  npm install react-confirm-lite
22
+ # or
23
+ yarn add react-confirm-lite
24
+ # or
25
+ pnpm add react-confirm-lite
44
26
  ```
45
27
 
46
- ### 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
+
47
34
  ```tsx
48
- import { confirm, ConfirmContainer } from 'react-confirm-lite';
49
- ```
35
+ import { ConfirmContainer } from 'react-confirm-lite';
50
36
 
51
- ### Step 3: Add ConfirmContainer to your component tree:
52
- ```jsx
53
37
  function App() {
54
38
  return (
55
- <>
56
- <ConfirmContainer />
39
+ <div>
57
40
  {/* Your app content */}
58
- </>
41
+ <ConfirmContainer />
42
+ </div>
59
43
  );
60
44
  }
61
45
  ```
62
46
 
63
- ### Step 4: Use the confirm function:
47
+ ### 2. Use the Confirm Function
48
+
49
+ Import and use `confirm()` anywhere in your app:
50
+
64
51
  ```tsx
65
- const handleAction = async () => {
66
- const isConfirmed = await confirm('Are you sure?');
67
- if (isConfirmed) {
68
- // Perform action
69
- 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!');
70
61
  }
71
- };
62
+ }
72
63
  ```
73
64
 
74
- ### Complete Example:
65
+ ## 🎯 Features
75
66
 
67
+ ### ✅ Simple Promise-based API
76
68
  ```tsx
77
- 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
+ ```
78
72
 
79
- function App() {
80
- const handleDelete = async () => {
81
- const isConfirmed = await confirm('Are you sure you want to delete this item?');
82
- if (isConfirmed) {
83
- // Delete logic here
84
- console.log('Item deleted');
85
- }
86
- };
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
+ ```
87
119
 
88
- return (
89
- <div>
90
- <button onClick={handleDelete}>Delete Item</button>
91
- <ConfirmContainer />
92
- </div>
93
- );
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');
94
137
  }
95
138
  ```
96
139
 
97
- ## 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
+ ```
98
150
 
99
- ### Custom Options:
151
+ ### Disable ESC and Backdrop Closing
100
152
  ```tsx
101
- const handleCustomConfirm = async () => {
102
- const isConfirmed = await confirm({
103
- title: "Delete Item",
104
- message: "This action cannot be undone. Are you sure?",
105
- cancelText: 'No, keep it',
106
- okText: 'Yes, delete',
107
- colorSchema: 'red',
108
- isDestructive: true
109
- });
110
-
111
- if (isConfirmed) {
112
- // Delete item
113
- }
114
- };
153
+ <ConfirmContainer
154
+ closeOnEscape={false}
155
+ closeOnClickOutside={false}
156
+ />
157
+ // Now dialog can only be closed with Cancel/OK buttons
115
158
  ```
116
159
 
117
- ### Custom Color Scheme:
118
- ```jsx
119
- <ConfirmContainer defaultColorSchema="light" />
120
- // 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
+ });
121
189
  ```
122
190
 
123
- ### Custom Styling:
124
- ```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
125
199
  <ConfirmContainer
126
200
  classes={{
127
- overlay: "bg-black/50",
128
- wrapper: "rounded-xl shadow-2xl",
129
- title: "text-2xl font-bold",
130
- message: "text-gray-600",
131
- button: "px-6 py-3 rounded-lg font-medium",
132
- cancel: "border border-gray-300 hover:bg-gray-50",
133
- 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
134
208
  }}
135
209
  />
136
210
  ```
137
211
 
138
- ### Fully Custom UI with Render Prop:
139
- ```jsx
212
+ ## 🎭 Custom UI with Render Prop
213
+
214
+ Want complete control over the UI? Use the render prop:
215
+
216
+ ```tsx
140
217
  <ConfirmContainer animationDuration={500}>
141
- {({ isVisible, confirm, handleCancel, handleOk }) => (
142
- <div className={`modal ${isVisible ? 'show' : 'hide'}`}>
143
- <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
+ >
144
237
  <h2>{confirm.title}</h2>
145
238
  <p>{confirm.message}</p>
146
- <div className="modal-actions">
239
+
240
+ <div className="buttons">
147
241
  <button onClick={handleCancel}>
148
242
  {confirm.cancelText || 'Cancel'}
149
243
  </button>
@@ -157,222 +251,238 @@ const handleCustomConfirm = async () => {
157
251
  </ConfirmContainer>
158
252
  ```
159
253
 
160
- ## 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
161
263
 
162
- Works automatically! No 'use client' directive needed for the library. The library handles everything internally.
264
+ ## 📱 Real-World Examples
163
265
 
164
- ### Server Components Example:
266
+ ### Delete Confirmation with ESC Disabled
165
267
  ```tsx
166
- // app/layout.tsx
167
- 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
+ });
168
277
 
169
- export default function RootLayout({
170
- children,
171
- }: {
172
- children: React.ReactNode;
173
- }) {
174
- return (
175
- <html lang="en">
176
- <body>
177
- {children}
178
- <ConfirmContainer />
179
- </body>
180
- </html>
181
- );
182
- }
183
- ```
184
- ```tsx
185
- // app/page.tsx (server component)
186
- 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
+ };
187
283
 
188
- export default async function Page() {
189
- // Server-side logic here
190
-
191
- return (
192
- <form action={async () => {
193
- 'use server';
194
- const isConfirmed = await confirm('Are you sure?');
195
- if (isConfirmed) {
196
- // Server action
197
- }
198
- }}>
199
- <button>Submit</button>
200
- </form>
201
- );
202
- }
284
+ // In your component
285
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={false} />
203
286
  ```
204
287
 
205
- ### Client Component Example:
288
+ ### Form Submission with Backdrop Only
206
289
  ```tsx
207
- 'use client';
208
- import { confirm, ConfirmContainer } from 'react-confirm-lite';
209
-
210
- export default function ClientComponent() {
211
- const handleClick = async () => {
212
- const result = await confirm('Confirm action?');
213
- if (result) {
214
- // Handle confirmation
215
- }
216
- };
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
+ });
217
301
 
218
- return (
219
- <div>
220
- <button onClick={handleClick}>Click me</button>
221
- <ConfirmContainer />
222
- </div>
223
- );
224
- }
302
+ if (result) {
303
+ await submitForm();
304
+ } else if (result === null) {
305
+ // User clicked backdrop
306
+ console.log('Closed by clicking outside');
307
+ }
308
+ };
225
309
  ```
226
310
 
227
- ## 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
+ />
228
318
 
229
- ### `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
+ ```
230
326
 
231
- Displays a confirmation dialog. Returns a promise that resolves to `true` if confirmed, `false` if cancelled.
327
+ ## 🏗️ Container Configuration
232
328
 
233
- **String usage:**
234
- ```ts
235
- await confirm('Simple message');
236
- // 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
+ />
237
340
  ```
238
341
 
239
- **Object usage:**
240
- ```ts
241
- await confirm({
242
- title: 'Warning',
243
- message: 'This action cannot be undone',
244
- cancelText: 'Cancel',
245
- okText: 'Delete',
246
- colorSchema: 'red',
247
- isDestructive: true
248
- });
249
- ```
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
250
347
 
251
- ### `ConfirmContainer` Props:
348
+ // Option 2: Force explicit choice
349
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={false} />
350
+ // Users can only close via: OK or Cancel buttons
252
351
 
253
- | Prop | Type | Default | Description |
254
- |------|------|---------|-------------|
255
- | `defaultColorSchema` | `ColorSchema` | `'dark'` | Default color scheme |
256
- | `animationDuration` | `number` | `300` | Animation duration in ms |
257
- | `classes` | `ConfirmClasses` | `{}` | Custom CSS classes |
258
- | `children` | Render function | - | For complete UI customization |
259
-
260
- ### Types:
261
- ```ts
262
- type ColorSchema = 'light' | 'dark' | 'blue' | 'red' | 'green' | 'purple';
263
-
264
- interface ConfirmClasses {
265
- overlay?: string;
266
- wrapper?: string;
267
- title?: string;
268
- message?: string;
269
- button?: string;
270
- cancel?: string;
271
- ok?: string;
272
- }
352
+ // Option 3: Backdrop only
353
+ <ConfirmContainer closeOnEscape={false} closeOnClickOutside={true} />
354
+ // Users can close via: OK, Cancel, or backdrop click
273
355
 
274
- interface ConfirmOptions {
275
- title?: string;
276
- message: string;
277
- cancelText?: string;
278
- okText?: string;
279
- colorSchema?: ColorSchema;
280
- isDestructive?: boolean;
281
- }
356
+ // Option 4: ESC only
357
+ <ConfirmContainer closeOnEscape={true} closeOnClickOutside={false} />
358
+ // Users can close via: OK, Cancel, or ESC key
282
359
  ```
283
360
 
284
- ## Troubleshooting
361
+ ## 🎨 Animation Gallery
285
362
 
286
- ### Dialog not appearing?
287
- - Make sure `<ConfirmContainer />` is rendered in your component tree
288
- - 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
289
368
 
290
- ### Multiple dialogs overlapping?
291
- - 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
292
374
 
293
- ### Styling not working?
294
- - If using custom classes, ensure they have proper CSS specificity
295
- - Try using `!important` flag for custom styles if needed
296
- - 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
297
379
 
298
- ### Animation issues with custom UI?
299
- - When using the `children` render prop, use the `isVisible` prop for animations
300
- - Set appropriate `animationDuration` to match your CSS transitions
380
+ ### Playful Animations
381
+ - `bounce` / `bounceSmall` - Bounce effects
382
+ - `zoom` / `zoomSmall` - Zoom in/out
301
383
 
302
- ### Next.js hydration errors?
303
- - The library is designed to work with Next.js App Router
304
- - If using in a layout, ensure it's placed after dynamic content
384
+ ## 🚨 Troubleshooting
305
385
 
306
- ## Features in Detail
386
+ ### Dialog not showing?
387
+ - Make sure `<ConfirmContainer />` is mounted
388
+ - Check it's not conditionally rendered
307
389
 
308
- ### 🎨 Multiple Color Schemes
309
- 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
310
394
 
311
- ### 🔄 Queue System
312
- 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
313
398
 
314
- ### 🎯 Zero Configuration
315
- 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
316
402
 
317
- ### 🔧 Fully Customizable
318
- 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
319
406
 
320
- ### 📱 Responsive Design
321
- Built-in responsive styling that works on all screen sizes.
407
+ ### Styling issues?
408
+ - Use `classes` prop to override styles
409
+ - Check CSS specificity
322
410
 
323
- ### 🔒 Type Safety
324
- Full TypeScript support with comprehensive type definitions.
411
+ ## 📱 Next.js Support
325
412
 
326
- ## Performance
327
-
328
- - **Zero dependencies**: Only React as a peer dependency
329
- - **Tree-shakeable**: Only imports what you use
330
- - **Small bundle size**: ~5KB gzipped (including styles)
331
- - **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';
332
417
 
333
- ## 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
+ ```
334
433
 
335
- 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';
336
439
 
337
- 1. **'use client' not needed**: The library handles this internally
338
- 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
+ ```
339
450
 
451
+ ## 🔄 Migration from Other Libraries
340
452
 
341
- ## Contributing
453
+ ### From window.confirm()
454
+ ```tsx
455
+ // Old way (always returns true/false)
456
+ if (window.confirm('Delete?')) {
457
+ deleteItem();
458
+ }
342
459
 
343
- 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
+ ```
344
470
 
345
- 1. Fork the repository
346
- 2. Create a feature branch
347
- 3. Add tests for your changes
348
- 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)
349
477
 
350
- ## Author
478
+ ## 📄 License
351
479
 
352
- **Saad Nasir** - Full Stack Developer
353
- - GitHub: [@SaadNasir-git](https://github.com/SaadNasir-git)
354
- - For support: Open an issue on GitHub
480
+ MIT License - free for personal and commercial use.
355
481
 
356
- ## License
482
+ ## 👨‍💻 Author
357
483
 
358
- MIT © Saad Nasir
484
+ **Saad Nasir** - Creator of react-confirm-lite
359
485
 
360
486
  ---
361
487
 
362
- ![npm version](https://img.shields.io/npm/v/react-confirm-lite)
363
- ![bundle size](https://img.shields.io/bundlephobia/minzip/react-confirm-lite)
364
- ![npm downloads](https://img.shields.io/npm/dm/react-confirm-lite)
365
- ![license](https://img.shields.io/npm/l/react-confirm-lite)
366
- ![typescript](https://img.shields.io/badge/types-TypeScript-blue)
367
- ![react](https://img.shields.io/badge/react-%3E%3D18-blue)
368
- ![next.js](https://img.shields.io/badge/next.js-15+-black)
369
-
370
- ## Support
371
-
372
- If you find this library helpful, please consider:
373
- - ⭐ Starring the repository on GitHub
374
- - 📢 Sharing with your network
375
- - 🐛 Reporting issues you encounter
376
- - 💡 Suggesting new features
377
-
378
- Happy coding! 🚀
488
+ **Found this useful? Give it a star on GitHub!** ⭐