{"id":13810075,"url":"https://github.com/Aslam97/react-confirm-dialog","last_synced_at":"2025-05-14T10:31:56.854Z","repository":{"id":246773184,"uuid":"822892240","full_name":"Aslam97/react-confirm-dialog","owner":"Aslam97","description":"React Confirm Dialog","archived":false,"fork":false,"pushed_at":"2025-05-08T17:15:24.000Z","size":461,"stargazers_count":151,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-10T12:18:09.994Z","etag":null,"topics":["alert-dialog","radix-ui","shadcn-ui"],"latest_commit_sha":null,"homepage":"https://react-confirm-dialog.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aslam97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-02T03:22:55.000Z","updated_at":"2025-05-08T17:15:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b41110f-4ccc-47d5-986f-badfd610f798","html_url":"https://github.com/Aslam97/react-confirm-dialog","commit_stats":null,"previous_names":["aslam97/react-confirm-dialog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslam97%2Freact-confirm-dialog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslam97%2Freact-confirm-dialog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslam97%2Freact-confirm-dialog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aslam97%2Freact-confirm-dialog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aslam97","download_url":"https://codeload.github.com/Aslam97/react-confirm-dialog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254120639,"owners_count":22018025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alert-dialog","radix-ui","shadcn-ui"],"created_at":"2024-08-04T02:00:45.052Z","updated_at":"2025-05-14T10:31:51.835Z","avatar_url":"https://github.com/Aslam97.png","language":"TypeScript","funding_links":[],"categories":["Libs and Components","Components","Components \u0026 Libraries"],"sub_categories":[],"readme":"# React Confirm Dialog\n\n\u003cp style={{ textAlign: 'center' }}\u003e\n\u003ca href=\"https://github.com/umodoc/editor/blob/main/LICENSE\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/%40omit%2Freact-confirm-dialog\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@omit/react-confirm-dialog\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/%40omit%2Freact-confirm-dialog\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@omit/react-confirm-dialog\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/%40omit%2Freact-confirm-dialog\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/umodoc/editor/commits\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/unpacked-size/%40omit%2Freact-confirm-dialog\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA flexible and customizable confirm dialog component for React applications, built with accessibility in mind.\n\n## Features\n\n- Easy to use with the `useConfirm` hook\n- Fully customizable appearance and behavior\n- Supports custom actions\n- Seamless integration with Shadcn UI\n\n## Installation\n\nInstall the package from npm:\n\n```bash\nnpm install @omit/react-confirm-dialog\n```\n\n## Usage\n\n### 1. Wrap your app with the ConfirmDialogProvider\n\n```jsx\nimport { ConfirmDialogProvider } from '@omit/react-confirm-dialog'\n\nfunction App() {\n  return (\n    \u003cConfirmDialogProvider\u003e{/* Your app components */}\u003c/ConfirmDialogProvider\u003e\n  )\n}\n```\n\n### 2. Use the useConfirm hook in your components\n\n```jsx\nimport { useConfirm } from '@omit/react-confirm-dialog'\n\nfunction YourComponent() {\n  const confirm = useConfirm()\n\n  const handleClick = async () =\u003e {\n    const isConfirmed = await confirm({\n      title: 'Delete Item',\n      description: 'Are you sure you want to delete this item?',\n      confirmText: 'Delete',\n      cancelText: 'Cancel'\n    })\n\n    if (isConfirmed) {\n      // Perform delete action\n    }\n  }\n\n  return \u003cbutton onClick={handleClick}\u003eDelete\u003c/button\u003e\n}\n```\n\n### 3. Update your Tailwind configuration\n\nAdd the library classes to your `tailwind.config.js`:\n\n```js\nmodule.exports = {\n  content: [\n    './node_modules/@omit/react-confirm-dialog/dist/index.js'\n    // ... your other content paths\n  ]\n  // ... other configurations\n}\n```\n\n## Configuration for Non-Shadcn UI Users\n\nIf you're not using Shadcn UI, follow these additional steps:\n\n### 1. Update your tailwind.config.js\n\n```js\nmodule.exports = {\n  theme: {\n    extend: {\n      colors: {\n        border: 'hsl(var(--border))',\n        input: 'hsl(var(--input))',\n        ring: 'hsl(var(--ring))',\n        background: 'hsl(var(--background))',\n        foreground: 'hsl(var(--foreground))',\n        primary: {\n          DEFAULT: 'hsl(var(--primary))',\n          foreground: 'hsl(var(--primary-foreground))'\n        },\n        secondary: {\n          DEFAULT: 'hsl(var(--secondary))',\n          foreground: 'hsl(var(--secondary-foreground))'\n        },\n        destructive: {\n          DEFAULT: 'hsl(var(--destructive))',\n          foreground: 'hsl(var(--destructive-foreground))'\n        },\n        muted: {\n          DEFAULT: 'hsl(var(--muted))',\n          foreground: 'hsl(var(--muted-foreground))'\n        },\n        accent: {\n          DEFAULT: 'hsl(var(--accent))',\n          foreground: 'hsl(var(--accent-foreground))'\n        }\n      }\n    }\n  },\n  plugins: [require('tailwindcss-animate')]\n}\n```\n\n### 2. Add CSS variables\n\nAdd these CSS variables to your main CSS file (or get your colors from [Shadcn UI](https://ui.shadcn.com/themes)):\n\n```css\n@layer base {\n  :root {\n    --background: 0 0% 100%;\n    --foreground: 240 10% 3.9%;\n    --primary: 240 5.9% 10%;\n    --primary-foreground: 0 0% 98%;\n    --secondary: 240 4.8% 95.9%;\n    --secondary-foreground: 240 5.9% 10%;\n    --muted: 240 4.8% 95.9%;\n    --muted-foreground: 240 3.8% 46.1%;\n    --accent: 240 4.8% 95.9%;\n    --accent-foreground: 240 5.9% 10%;\n    --destructive: 0 84.2% 60.2%;\n    --destructive-foreground: 0 0% 98%;\n    --border: 240 5.9% 90%;\n    --input: 240 5.9% 90%;\n    --ring: 240 5.9% 10%;\n    --radius: 0.5rem;\n  }\n\n  .dark {\n    --background: 240 10% 3.9%;\n    --foreground: 0 0% 98%;\n    --primary: 0 0% 98%;\n    --primary-foreground: 240 5.9% 10%;\n    --secondary: 240 3.7% 15.9%;\n    --secondary-foreground: 0 0% 98%;\n    --muted: 240 3.7% 15.9%;\n    --muted-foreground: 240 5% 64.9%;\n    --accent: 240 3.7% 15.9%;\n    --accent-foreground: 0 0% 98%;\n    --destructive: 0 62.8% 30.6%;\n    --destructive-foreground: 0 0% 98%;\n    --border: 240 3.7% 15.9%;\n    --input: 240 3.7% 15.9%;\n    --ring: 240 4.9% 83.9%;\n  }\n}\n```\n\n## Advanced Usage\n\n### Custom Content Slot\n\nYou can add additional content between the description and actions:\n\n```jsx\nhandleClick = async () =\u003e {\n  const isConfirmed = await confirm({\n    title: 'Custom Content',\n    description: 'This dialog includes custom content.',\n    contentSlot: \u003cCustomComponent /\u003e\n  })\n}\n```\n\n### Custom Actions\n\nThe library supports custom actions API that provides access to the dialog's configuration:\n\n```jsx\nconst handleClick = async () =\u003e {\n  const isConfirmed = await confirm({\n    title: 'Custom Actions',\n    customActions: ({ confirm, cancel, config, setConfig }) =\u003e (\n      \u003cdiv\u003e\n        \u003cbutton\n          onClick={() =\u003e {\n            setConfig((prev) =\u003e ({ ...prev, title: 'Updated Title' }))\n          }}\n        \u003e\n          Update Title\n        \u003c/button\u003e\n        \u003cbutton onClick={confirm}\u003eConfirm\u003c/button\u003e\n        \u003cbutton onClick={cancel}\u003eCancel\u003c/button\u003e\n      \u003c/div\u003e\n    )\n  })\n}\n```\n\n### Dynamic Configuration Updates\n\nYou can update the dialog's configuration even after it's opened:\n\n```jsx\nconst confirm = useConfirm()\n\nconfirm.updateConfig((prev) =\u003e ({\n  ...prev,\n  description: 'Updated description'\n}))\n```\n\n### Default Options\n\nYou can set default options for all confirm dialogs in your app:\n\n```jsx\n\u003cConfirmDialogProvider\n  defaultOptions={{\n    confirmText: 'Yes',\n    cancelText: 'No',\n    confirmButton: {\n      variant: 'destructive',\n      size: 'sm'\n    },\n    cancelButton: {\n      variant: 'outline',\n      size: 'sm'\n    },\n    alertDialogContent: {\n      className: 'sm:max-w-[425px]'\n    }\n  }}\n\u003e\n  {/* Your app components */}\n\u003c/ConfirmDialogProvider\u003e\n```\n\n## API Reference\n\n### ConfirmOptions\n\nThe `confirm` function accepts an options object with the following properties:\n\n```typescript\ninterface ConfirmOptions {\n  // Content\n  title?: ReactNode\n  description?: ReactNode\n  contentSlot?: ReactNode\n  icon?: ReactNode\n\n  // Button Text\n  confirmText?: string\n  cancelText?: string\n\n  // Custom Actions\n  customActions?: LegacyCustomActions | EnhancedCustomActions\n\n  // Button Props\n  confirmButton?: ComponentPropsWithRef\u003ctypeof AlertDialogAction\u003e\n  cancelButton?: ComponentPropsWithRef\u003ctypeof AlertDialogCancel\u003e | null\n\n  // Component Props\n  alertDialogOverlay?: ComponentPropsWithRef\u003ctypeof AlertDialogOverlay\u003e\n  alertDialogContent?: ComponentPropsWithRef\u003ctypeof AlertDialogContent\u003e\n  alertDialogHeader?: ComponentPropsWithRef\u003ctypeof AlertDialogHeader\u003e\n  alertDialogTitle?: ComponentPropsWithRef\u003ctypeof AlertDialogTitle\u003e\n  alertDialogDescription?: ComponentPropsWithRef\u003ctypeof AlertDialogDescription\u003e\n  alertDialogFooter?: ComponentPropsWithRef\u003ctypeof AlertDialogFooter\u003e\n}\n```\n\n## Tailwind CSS Intellisense\n\nTo enable class name completion for the `className` prop, add this to your editor settings:\n\n```diff\n{\n  \"tailwindCSS.experimental.classRegex\": [\n    \"class:\\\\s*?[\\\"'`]([^\\\"'`]*).*?,\",\n+    \"className:\\\\s*[\\\"']([^\\\"']*)[\\\"']\"\n  ]\n}\n```\n\n## Related Projects\n\n- [Minimal Tiptap Editor](https://github.com/Aslam97/shadcn-minimal-tiptap)\n- [React Fancy Switch](https://github.com/Aslam97/react-fancy-switch)\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAslam97%2Freact-confirm-dialog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAslam97%2Freact-confirm-dialog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAslam97%2Freact-confirm-dialog/lists"}