ToastAlerts Demo

Advanced Toast Component for Bootstrap 5.3 with dynamic creation, positioning, queueing, and accessibility features.

Toast Settings
Statistics
Visible Toasts: 0
Queued Toasts: 0
Quick Actions
Test Scenarios
Features Overview
Core Features
  • Dynamic toast creation
  • Multiple positioning options
  • Queue management with priority
  • Custom animation effects
  • Auto-hide with pause/resume
  • Progress indicators
Advanced Features
  • Touch gesture support
  • Keyboard navigation
  • Screen reader compatibility
  • Theme system integration
  • Event system with callbacks
  • Template customization
API Examples

// Initialize ToastAlerts
const toastAlerts = new ToastAlerts();

// Show a simple toast
toastAlerts.show('Hello, World!');

// Show with options
toastAlerts.show('Success message!', {
	type: 'success',
	position: 'top-right',
	duration: 5000
});

// Toast with callbacks
toastAlerts.show('Processing...', {
	type: 'info',
	persistent: true,
	callbacks: {
		shown: (toast) => console.log('Toast shown:', toast.id),
		hidden: (toast) => console.log('Toast hidden:', toast.id)
	}
});

// Update existing toast
const toastId = toastAlerts.show('Loading...');
setTimeout(() => {
	toastAlerts.update(toastId, 'Complete!', { type: 'success' });
}, 2000);

// Register custom template
toastAlerts.templates.register('custom', `
	<div class="toast" role="alert">
		<div class="toast-body">
			<strong>{{title}}</strong>
			<p>{{content}}</p>
		</div>
	</div>
`);

// Use custom template
toastAlerts.show('Custom content', {
	template: 'custom',
	title: 'Custom Title'
});

// Listen to global events
document.addEventListener('shown.toast-alerts', (e) => {
	console.log('Toast shown:', e.detail);
});

document.addEventListener('hidden.toast-alerts', (e) => {
	console.log('Toast hidden:', e.detail);
});

// Queue management
document.addEventListener('queueUpdated.toast-alerts', (e) => {
	console.log('Queue updated:', e.detail.queue);
});
Keyboard Shortcuts
Demo Controls:
  • Ctrl/Cmd + S - Show demo toast
  • Ctrl/Cmd + H - Hide all toasts
  • 1-4 - Quick toast types
Toast Navigation:
  • Tab - Focus toast
  • Enter/Space - Interact with toast
  • Escape - Close focused toast
Browser Support
Fully Supported
  • Chrome 80+
  • Firefox 75+
  • Safari 13+
  • Edge 80+
Graceful Degradation
  • IE 11 (limited animations)
  • Older mobile browsers
  • Respects reduced motion preferences