npm install notify-boltyarn add notify-boltimport { showNotify } from "notify-bolt";
const handleClick = () => {
showNotify({
title: "Delete this item?",
message: "This action is permanent. Do you wish to proceed?",
variant: "classic",
status: "warning",
showConfirmButton: true,
showCancelButton: true,
})
.then(() => {
// User confirmed
})
.catch(() => {
// User dismissed
});
};The title displayed at the top of the modal. Accepts plain text or a React component for rich content.
Accepted Types:string,React.ReactNode.
showNotify({ title: "Are you sure?" });showNotify({ title: <strong>Important Notice</strong> });The main body content of the modal. Can be simple text or a custom JSX structure.
Accepted Types:string,React.ReactNode.
showNotify({ message: "This action cannot be undone." });showNotify({ message: <p>Please <em>read carefully</em> before proceeding.</p> });Determines the modal's theme (color and icon) based on the context, like 'success' or 'error'.
Accepted Types:success,error,warning,info,default.
showNotify({ status: "success" });Sets the modal's layout style. 'Classic' for traditional, 'Default' for a simpler appearance.
Accepted Types:classic,default.
showNotify({ variant: "classic" });Adjusts the size of the modal window. Useful for alerts, confirmations, and larger dialogs.
Accepted Types:xs,sm,md,lg.
showNotify({ size: "xs" });Custom icon for the modal. Accepts emoji strings, custom React elements.
Accepted Types:string,React.ReactNode,status.
showNotify({ icon: "🔥" });showNotify({ icon: <CustomIcon /> });Specifies whether the icon is rendered in a filled ('classic') or outlined style.
Accepted Types:classic,outline.
showNotify({ iconType: "classic" });If true, displays a confirm button for positive actions.
Accepted Types:boolean.
showNotify({ showConfirmButton: true });Label text or JSX for the confirm button.
Accepted Types:string,React.ReactNode.
showNotify({ confirmButtonText: "Yes, continue" });showNotify({ confirmButtonText: <span>Proceed</span> });If true, shows a cancel button for dismissing the modal without action.
Accepted Types:boolean.
showNotify({ showCancelButton: true });Custom label for the cancel button.
Accepted Types:string,React.ReactNode.
showNotify({ cancelButtonText: "Abort" });showNotify({ cancelButtonText: <strong>Cancel</strong> });If true, displays a deny button, offering an alternative to confirm/cancel.
Accepted Types:boolean.
showNotify({ showDenyButton: true });Label text or JSX for the deny button.
Accepted Types:string,React.ReactNode.
showNotify({ denyButtonText: "No, thanks" });showNotify({ denyButtonText: <span>Refuse</span> });Whether a close (X) icon is displayed on the modal header.
Accepted Types:boolean.
showNotify({ showCloseIcon: false });Custom close icon element or string label.
Accepted Types:string,React.ReactNode.
showNotify({ closeIcon: "❌" });showNotify({ closeIcon: <div>X</div> });Switches between light and dark theme modes for modal appearance.
Accepted Types:light,dark.
setNotifyDefaults({ mode: "dark" });Specifies the entrance animation style for the modal transition.
Accepted Types:fade,slide-up,slide-down,slide-left,slide-right,zoom-in,zoom-out.
showNotify({ animation: "zoom-in" });Automatically closes the modal after the specified time (in milliseconds).
Accepted Types:number.
showNotify({ timer: 3000 });Shows a visual progress bar when timer is active.
Accepted Types:boolean.
showNotify({ timerProgressBar: true });Enables closing the modal by clicking outside of it.
Accepted Types:boolean.
showNotify({ allowOutsideClick: true });Automatically focuses the confirm button when the modal appears.
Accepted Types:boolean.
showNotify({ focusConfirm: true });Callback function triggered immediately after the modal is opened.
Accepted Types:() => void.
showNotify({ onDidOpen: () => console.log("Modal opened!") });Callback function triggered right before the modal closes.
Accepted Types:() => void.
showNotify({ onWillClose: () => console.log("Modal closing...") });Triggers a celebration animation (like confetti) when the modal opens.
Accepted Types:boolean.
showNotify({ celebrate: true });Specifies the type of celebration animation to display when 'celebrate' is true.
Accepted Types:basic,random,realistic,fireworks,snow,pride.
showNotify({ celebrationType: "fireworks" });Completely custom modal body. Can access action handlers for confirm/deny within the template function.
Accepted Types:React.ReactNode,(actions: { resolve: () => void; reject: () => void }) => React.ReactNode.
showNotify({ template: <div>Custom Modal</div> });showNotify({ template: ({ resolve, reject }) => (
<div>
<p>Custom Content</p>
<button onClick={resolve}>Accept</button>
<button onClick={reject}>Decline</button>
</div>
) });Programmatic handler to resolve the modal manually with 'confirm' or 'deny'. This behaves like a promise `.then()` handler.
Accepted Types:("confirm" | "deny") => void).
showNotify({
title:"testing"
}).then((res) => {
if (res === "confirm") {
// Handle confirm logic
console.log("Confirmed!");
} else if (res === "deny") {
// Handle deny logic
console.log("Denied!");
}
});Function to reject the modal action. This behaves like a promise `.catch()` handler.
Accepted Types:() => void.
showNotify({
title:"testing"
}).catch((error) => {
// Handle reject logic
console.log("Action rejected", error);
});Custom inline styles to override modal components like button, modal container, overlay, etc.
Accepted Types:object.
showNotify({
style: {
modal: { backgroundColor: "lightblue" },
title: { color: "darkblue" },
button: { backgroundColor: "green" }
}
});showNotify.import { setNotifyDefaults } from "notify-bolt";
setNotifyDefaults({
mode: "light",
defaultSize: "sm",
allowOutsideClick: true,
style: {},
});