Installation
<link rel="stylesheet" href="toastify.css">
<script src="toastify.js"></script>
Live Demo
With Icon
Without Icon
Auto Dismiss
Manual Close (no auto-dismiss)
Position — Top
Position — Bottom
Position — Middle
API Reference
onvsToast(icon, type, message, subMessage, close, position)
| # |
Parameter |
Type |
Description |
| 1 |
icon |
boolean |
true = show SVG icon · false = no icon |
| 2 |
type |
string |
'success' · 'info' · 'warning' · 'danger' |
| 3 |
message |
string | null |
Main text — pass null for default "Message" |
| 4 |
subMessage |
string | null |
Small text below message — pass null to omit |
| 5 |
close |
number | false |
Auto-dismiss duration in ms — false = close button only |
| 6 |
position |
string |
See position table below |
Position values
| Value |
Description |
'top-left' | Top left corner |
'top-center' | Top center |
'top-right' | Top right corner (default) |
'bottom-left' | Bottom left corner |
'bottom-center' | Bottom center |
'bottom-right' | Bottom right corner |
'middle' | Center of screen |
Code Examples
With icon + sub-message + auto dismiss
onvsToast(true, 'success', 'Data berhasil disimpan', 'Record tersimpan ke database', 4000, 'top-right')
Without icon, no sub-message
onvsToast(false, 'danger', 'Gagal menyimpan', null, 3000, 'top-right')
Manual close only (no auto-dismiss)
onvsToast(true, 'warning', 'Konfirmasi diperlukan', 'Klik ✕ untuk menutup', false, 'middle')
Quick dismiss (1 s)
onvsToast(true, 'info', 'Tersimpan!', null, 1000, 'bottom-right')
Type Colors
| Type | Color |
success | #2ab57d |
info | #4ba6ef |
warning | #ffbf53 |
danger | #fd625e |