A simple, dependency-free, and customizable alert modal built using Tailwind CSS and vanilla JavaScript.
Include the script in your HTML:
<script src="TailwindAlert.js"></script>
Make sure Tailwind CSS is included in your project:
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
Trigger the alert using JavaScript:
TailwindAlert.show({
title: "Delete Item",
message: "Are you sure you want to delete this?",
type: "warning",
onConfirm: () => alert("Confirmed!"),
onCancel: () => alert("Cancelled!")
});
TailwindAlert.show(options)
Option | Type | Description |
---|---|---|
title |
string | Title of the alert |
message |
string | Message body of the alert |
type |
string | Alert type (e.g., success , error , warning ) |
onConfirm |
function | Callback for Confirm button |
onCancel |
function | Callback for Cancel button |
You can edit the styling directly in the TailwindAlert.js
file to match your theme or branding.
MIT License
Created by [Your Name]. Contributions are welcome!