Confirm Alert

A Confirm Alert component is a UI element that prompts users to confirm or cancel an action before proceeding. It typically displays a message asking for confirmation, along with "Confirm" and "Cancel" buttons, ensuring that the user consciously approves or rejects the action, often used for critical tasks like deletions or irreversible changes.
# Demo
# Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
titleClassNamestring' 'You can customise by passing tailwind classes.
messageClassNamestring' 'You can customise by passing tailwind classes.
confirmClassNamestring' 'You can customise by passing tailwind classes.
cancelClassNamestring' 'You can customise by passing tailwind classes.
titlestringAre you absolutely sure?You can pass title for confirm alert.
messagestringRequiredYou can pass message for confirm alert.
confirmTextstringConfirmYou can pass confirmText for confirm alert.
cancelTextstringCancelYou can pass cancelText for confirm alert.
isOpenbooleanfalseYou can pass isOpen to show / hide alert box.
onClose() => voidRequiredYou can get callback when confirm alert got closed.
onResult(result: boolean) => voidRequiredYou can get callback when alert confirmed / cancelled.
# Usage
import { useState } from 'react'; import { NConfirmAlert, NButton } from 'nayan'; const ConfirmAlert = () => { const [isOpen, setIsOpen] = useState(false); return ( <div> <NConfirmAlert isOpen={isOpen} title="Are you absolutely sure?" message="This action cannot be undone. This will permanently delete your account and remove your data from our servers." onResult={result => console.log('Alert Clicked', result)} onClose={() => setIsOpen(false)} /> <NButton onClick={() => setIsOpen(true)}>Show Alert</NButton> </div> ); }; export default ConfirmAlert;