// Successsadrazam.Snackbar.insert({ success: 'Record saved successfully.' });
// Errorsadrazam.Snackbar.insert({ error: 'Something went wrong. Please try again.' });
// Warningsadrazam.Snackbar.insert({ warning: 'Check your input before submitting.' });
// Noticesadrazam.Snackbar.insert({ notice: 'Scheduled maintenance tonight at 11 PM.' });
// Plain string (no special styling)sadrazam.Snackbar.insert('A simple text message');
Multiple Messages per Type
Pass an array of strings to show a bulleted list inside one type group
Error List{ error: ['msg1', 'msg2', 'msg3'] }
Success List{ success: ['msg1', 'msg2'] }
// Multiple error messages displayed as a bulleted listsadrazam.Snackbar.insert({
error: [
'Name field is required.',
'Email address is invalid.',
'Password must be at least 8 characters.'
]
});
// Multiple success messagessadrazam.Snackbar.insert({
success: ['Profile updated.', 'Avatar uploaded.']
});
Mixed Types in One Call
A single insert() call can display multiple type groups stacked together
// Mixed: success + error in one notificationsadrazam.Snackbar.insert({
success: '2 items imported successfully.',
error: ['Row 5: missing email.', 'Row 12: duplicate entry.']
});
// All four types at oncesadrazam.Snackbar.insert({
success: 'Settings saved.',
warning: 'API rate limit is near 80%.',
error: 'Failed to sync with remote server.',
notice: 'New version available (v2.4.0).'
});
Duration & Auto-Dismiss
The second parameter controls how long the toast stays on screen (in milliseconds)
Default (5s)insert('...') // default 5000ms
Short (2s)insert('...', 2000)
Long (10s)insert('...', 10000)
Persistentinsert('...', false)
// Default 5-second auto-dismisssadrazam.Snackbar.insert('Disappears in 5 seconds.');
// Quick 2-second flashsadrazam.Snackbar.insert('Quick flash!', 2000);
// Longer 10-second displaysadrazam.Snackbar.insert('I will stay for 10 seconds.', 10000);
// Persistent: stays until the user clicks the close buttonsadrazam.Snackbar.insert({ warning: 'This will not auto-close. Click X to dismiss.' }, false);
Singleton Behavior
Only one notification is visible at a time. Calling insert() again replaces the current toast immediately.
Replace DemoClick "First Toast" then quickly click "Replace with Second"
// First toast appearssadrazam.Snackbar.insert({ notice: 'Loading data...' }, false);
// Calling insert() again replaces the previous onesadrazam.Snackbar.insert({ success: 'Data loaded! Previous toast was replaced.' });
Close Button & Group Dismissal
Each type group has its own close button (ph-x icon). Closing all groups removes the wrapper entirely.
Try ItClick the X on each group to close them individually
// Show three groups - close each one individually with the X buttonsadrazam.Snackbar.insert({
success: 'Upload complete.',
warning: 'File size is large (48 MB).',
error: 'Thumbnail generation failed.'
}, false);
Real-World Examples
Typical usage patterns you might encounter in production
Form Validation
Save Confirm
Delete Confirm
Import Report
// Form validation errorssadrazam.Snackbar.insert({
error: [
'Name is required.',
'Email format is invalid.',
'Phone number must be 10 digits.',
'Password and confirmation do not match.'
]
});
// Successful savesadrazam.Snackbar.insert({ success: 'Record #1042 saved successfully.' }, 3000);
// CSV import results (mixed)sadrazam.Snackbar.insert({
success: ['120 rows imported.', '3 duplicates merged.'],
warning: '5 rows skipped due to missing required fields.',
error: ['Row 88: invalid date format.', 'Row 102: unknown category code.']
}, false);
Static (Inline) Notifications
The same CSS classes can be used as inline, static notifications within page content (without JS)
Your profile has been updated successfully.
Access denied. You do not have permission to view this page.
Your subscription expires in 3 days.
Please update your payment method.
A new software update is available. Version 3.2.1 includes bug fixes and performance improvements.
<!-- Static notification embedded in page (no JS needed) -->
<div class="snackbar__static-container snackbar__static-container--success">
<ul class="snackbar__static-list">
<li>Your profile has been updated.</li>
</ul>
</div>
<!-- Multiple messages become a bulleted list -->
<div class="snackbar__static-container snackbar__static-container--warning">
<ul class="snackbar__static-list">
<li>Subscription expires in 3 days.</li>
<li>Please update your payment method.</li>
</ul>
</div>
Console Helper
Run Sadrazam.Snackbar.help() in your browser console to see all available configuration options