Introducing KAlert.js β A Lightweight Modern Alert Dialog Library for JavaScript π
While working on my frontend projects, I often needed a clean and modern alternative to the default browser alert dialogs.
The native browser alert:
alert("Hello world");
is functional, but it looks outdated and isn't customizable.
So I built KAlert.js β a lightweight, animated, Promise-based alert dialog library that works instantly via CDN with zero setup required.
β¨ Features
KAlert.js provides:
β
Animated modal dialogs
β
Promise-based confirm dialogs
β
Font Awesome icon support (auto-loaded)
β
Blur background overlay
β
Success / error / warning / info alert types
β
Zero dependencies
β
CDN-ready usage
β
Lightweight and fast
π¦ Install via CDN (No setup required)
Just include one script:
<script src="https://cdn.jsdelivr.net/gh/TutorialsAndroid/KAlert@v1.1.1/kalertdialog.js"></script>
Thatβs it.
No configuration needed.
π Basic Usage Example
Show a success alert:
KAlert.show("Saved successfully!", "success");
Other supported alert types:
success
error
warning
info
Example:
KAlert.show("Something went wrong!", "error");
β Confirm Dialog Example (Promise-Based)
Unlike traditional confirm dialogs, KAlert uses a modern Promise API:
KAlert.confirm("Delete this file?")
.then(result => {
if(result){
console.log("User confirmed");
}else{
console.log("User cancelled");
}
});
This makes it easier to integrate into modern JavaScript workflows.
π¨ Alert Types Available
KAlert currently supports:
π’ success
π΄ error
π‘ warning
π΅ info
Each alert includes animated UI and Font Awesome icons automatically.
π‘ Why I Built This Library
Many alert dialog libraries are powerful but often:
β’ too large
β’ require configuration
β’ need multiple imports
β’ depend on frameworks
KAlert.js focuses on simplicity:
One script.
Instant usage.
Clean UI.
π§ͺ Live Example
KAlert.show("Welcome to KAlert!", "info");
KAlert.confirm("Continue?")
.then(result => console.log(result));
π GitHub Repository
You can check out the project here:
https://github.com/TutorialsAndroid/KAlert
Feedback, suggestions, and contributions are welcome!
π Roadmap
Planned features for upcoming versions:
β’ custom dialog titles
β’ input prompt dialogs
β’ dark mode support
β’ theme customization
β’ button text customization
If youβre building frontend projects and want a clean alert dialog alternative without extra setup, give KAlert.js a try.
Iβd love to hear your feedback π
Top comments (0)