Lightweight, zero-dependency alert dialog for any web project. Just two files — drop in and go.
<link rel="stylesheet" href="alert.css">
<script src="alert.js"></script>
onvsAlert(icon, type, title, message, buttons)
| Parameter | Type | Description |
|---|---|---|
icon |
boolean |
true = show icon · false = no icon |
type |
string |
'success' · 'danger' · 'warning' · 'info' |
title |
string |
Alert heading text |
message |
string | null |
Sub-text below the title — pass null to omit |
buttons |
object |
Button configuration (see below) |
{
confirm: {
label : 'Delete', // button label
icon : 'trash', // 'trash' | 'check' | 'x' | 'ok'
color : '#fd625e', // optional — defaults to type color
onClick: () => {} // optional callback
},
cancel: { // optional — omit for close-only
label : 'Cancel',
icon : 'x',
onClick: () => {}
}
}
onvsAlert(true, 'success', 'Berhasil!', 'Data berhasil disimpan.', {
confirm: { label: 'OK', icon: 'ok' }
})
onvsAlert(true, 'success', 'Simpan Perubahan?', 'Pastikan data sudah benar.', {
confirm: {
label : 'Confirm',
icon : 'check',
onClick: () => console.log('confirmed')
},
cancel: { label: 'Cancel', icon: 'x' }
})
onvsAlert(true, 'danger', 'Hapus Data?', 'Data tidak bisa dikembalikan.', {
confirm: {
label : 'Delete',
icon : 'trash',
onClick: () => onvsAlert(true, 'success', 'Dihapus!', 'Data berhasil dihapus.', {
confirm: { label: 'OK', icon: 'ok' }
})
},
cancel: { label: 'Cancel', icon: 'x' }
})