A multi-purpose alert/confirm/prompt replacement built with shadcn/ui AlertDialog components.
✓ Published0🌍 Public
JJastor11
Last edited Apr 2, 2023
Created on Apr 18, 2025
This example demonstrates a reusable dialog system that replaces native alert, confirm, and prompt functions with promise-based APIs. It provides `useAlert`, `useConfirm`, and `usePrompt` hooks that return resolved values—booleans or strings—when the user interacts with the dialog. The implementation uses React’s Context API, `useReducer`, and `useRef` to manage state across an `AlertDialogProvider` component. The UI is built with shadcn/ui’s `AlertDialog`, `Button`, and `Input` components, all rendered inside a form that submits to close the dialog and resolve the pending promise.
AI-generated description