beautyalert
v1.0.0
Published
A lightweight TypeScript library, created as a drop-in replacement for showing beautiful, customizable alerts and modal dialogs. Fully open-source and dependency-free.
Maintainers
Readme
📦 BeautyAlert
A lightweight TypeScript library, created as a drop-in replacement for showing beautiful, customizable alerts and modal dialogs. Fully open-source and dependency-free.
✨ Features
✅ Written in TypeScript
✅ No external dependencies
✅ Customizable title, text, and buttons
✅ Optional cancel button
✅ Supports promise-based result handling
✅ Easy to style with CSS
📦 Installation
npm install beautyalert
Or with yarn:
yarn add beautyalert
Or with pnpm:
pnpm i beautyalert
🚀 Usage
import Swal from "beautyalert";
Swal.fire({
title: "Hello!",
text: "This is a simple alert",
});With confirm/cancel:
import Swal from "beautyalert";
Swal.fire({
title: "Are you sure?",
text: "This action cannot be undone",
showCancelButton: true,
confirmButtonText: "Yes",
cancelButtonText: "No"
}).then((result) => {
if (result) {
console.log("Confirmed!");
} else {
console.log("Cancelled!");
}
});⚙️ API
Swal.fire(options: SweetAlertOptions): Promise<boolean>
Options
| Option | Type | Default | Description | |---|---|---|---| | title | string | '' | Title text displayed in the modal | | text | string | '' | Main content text | | icon | string | "success", "error", "warning", "info", "question" | (Planned) Icon type | | confirmButtonText | string | "OK" | Confirm button text | | cancelButtonText | string | "Cancel" | Cancel button text | | showCancelButton | boolean | false | Whether to show a cancel button |
Returns
A Promise<boolean>:
- true → user clicked confirm
- false → user clicked cancel
🛠 Development
Clone the repo and run:
npm install
npm run dev
This starts a Vite playground at http://localhost:3000 for testing.
Build the library:
npm run build
Output will be in the dist/ directory.
📌 Roadmap
[ ] Add icons (success, error, warning, info, question)
[ ] Add animations
[ ] Add input fields (text, checkbox, select)
[ ] Theming support
📄 License
MIT © 2025
