sajilo-alert
v1.1.1
Published
<p align="center"> <a href="https://sajilo-alert.ankitak.com.np/"> <img alt="SajiloAlert" src="https://sajilo-alert.ankitak.com.np/logo.png" width="150" style="border-radius: 20px;"> </a> </p>
Maintainers
Readme
Installation
$ npm install sajilo-alertUsage
import { alert } from 'sajilo-alert';
alert.success("काम सफल भयो!");Documentation
Full documentation, interactive guides, and a live playground are available on the official website:
Examples
Basic Alerts:
alert.success("Operation completed successfully.");
alert.error("An unexpected error occurred.");
alert.warning("Please check your input data.");
alert.info("A new software update is available.");A confirmation dialog (returns a Promise resolving to a boolean):
- Using async/await:
const isConfirmed = await alert.confirm({
title: "Delete Account?",
message: "This action cannot be undone.",
confirmText: "Delete",
cancelText: "Cancel"
});
if (isConfirmed) {
alert.success("Account deleted successfully!");
}- Using promises:
alert.confirm({
title: "Log out?",
message: "Are you sure you want to log out?"
})
.then((isConfirmed) => {
if (isConfirmed) {
alert.toast.info("Logged out successfully.");
}
});Handling Async Operations with Promises:
await alert.promise(fetchData(), {
loading: "Loading data...",
success: (data) => `Data received: ${data.name}!`,
error: "Failed to load data!"
});Non-blocking Toast Notifications:
alert.toast.success("Settings saved successfully.");
alert.toast.error("Network disconnected!");Theming & Configuration
SajiloAlert comes with 4 built-in themes (nepal, light, dark, minimal) and native bilingual support (English and Nepali).
alert.configure({
theme: "nepal",
language: "en", // 'en' or 'ne'
position: "center",
duration: 4000,
closeOnEscape: true
});Read more about customization and themes
License
This project is licensed under the MIT License — see the LICENSE file for details.
