Alert / Dialog

JavaScript alert and dialog system.

Setup

Import the alert script in your page:

<script>
import "@/components/ui/scripts/alert.js";
</script>

Basic Alert

window.showAlert({
type: "success",
variant: "soft",
title: "Success",
text: "Operation completed successfully!",
icon: true,
duration: 3000,
});

Confirmation Dialog

window.showAlert({
type: "warning",
variant: "soft",
title: "Are you sure?",
text: "This action cannot be undone.",
icon: true,
buttons: [
{
text: "Cancel",
variant: "outline",
size: "sm",
type: "warning",
},
{
text: "Confirm",
variant: "solid",
size: "sm",
type: "warning",
onClick: () => {
// Handle confirmation
},
},
],
});

Options

OptionTypeDescription
typestringAlert type (success, error, warning, info)
variantstringStyle variant (soft, solid)
titlestringAlert title
textstringAlert message
iconbooleanShow type icon
durationnumberAuto-dismiss in milliseconds
positionobject{ vertical, horizontal }
buttonsarrayButton configurations

Button Options

OptionTypeDescription
textstringButton text
variantstringStyle (solid, outline, soft)
sizestringSize (sm, md, lg)
typestringColor type
iconstringIcon class
onClickfunctionClick handler