-
Notifications
You must be signed in to change notification settings - Fork 3
Home
The Ultimate Lightweight Toast Notification Library
Modern โข Customizable โข Framework Agnostic โข Zero Dependencies
๐ Live Demo โข ๐ Documentation โข ๐ก Examples โข ๐ Issues
The fastest, smallest, and most flexible toast notification library available. Perfect replacement for SweetAlert, Toastr, React-Toastify, and other heavy alternatives.
| ๐ Toastify Pro | ๐ฆ SweetAlert2 | ๐ Toastify JS | โ๏ธ React-Toastify | ๐ฏ Notyf |
|---|---|---|---|---|
| ~2KB | ~45KB | ~8KB | ~15KB | ~3KB |
| โ Zero deps | โ Heavy | โ Lightweight | โ React only | โ Small |
| โ 6 themes | โ Customizable | โ Limited | โ Themeable | โ Basic |
| โ All frameworks | โ Vanilla only | โ Vanilla only | โ React only | โ Universal |
|
|
```bash
npm install toastify-pro
yarn add toastify-pro
pnpm add toastify-pro ```
```html
<script src="https://cdn.jsdelivr.net/npm/toastify-pro@latest/dist/toastify-pro.umd.min.js"></script>```
```javascript import ToastifyPro from 'toastify-pro';
const toast = new ToastifyPro();
// Show different types of notifications
toast.success('โ
Operation completed successfully!');
toast.error('โ Something went wrong!');
toast.warning('
๐ Try it Now: Interactive Demo
```jsx import React, { useEffect, useState } from 'react'; import ToastifyPro from 'toastify-pro';
function App() { const [toast, setToast] = useState(null);
useEffect(() => {
setToast(new ToastifyPro({
position: 'top-right',
timeout: 3000,
allowClose: true
}));
}, []);
return (
<div>
<button onClick={() => toast?.success('๐ React integration works!')}>
Show Success Toast
</button>
<button onClick={() => toast?.error('๐ฅ Error handling demo')}>
Show Error Toast
</button>
</div>
);
} ```
```vue
<script> import ToastifyPro from 'toastify-pro'; export default { mounted() { this.toast = new ToastifyPro({ position: 'bottom-right', timeout: 4000 }); }, methods: { showSuccess() { this.toast.success('๐ฏ Vue.js integration successful!'); }, showError() { this.toast.error('๐จ Error in Vue component!'); } } }; </script>```
```typescript import { Component, OnInit } from '@angular/core'; import ToastifyPro from 'toastify-pro';
@Component({
selector: 'app-toast-demo',
template: <button (click)="showSuccess()">Success Toast</button> <button (click)="showError()">Error Toast</button>
})
export class ToastDemoComponent implements OnInit {
private toast: ToastifyPro;
ngOnInit() {
this.toast = new ToastifyPro({
position: 'top-center',
timeout: 3500
});
}
showSuccess() {
this.toast.success('๐ Angular integration works!');
}
showError() {
this.toast.error('โ ๏ธ Error in Angular component!');
}
} ```
```html
<title>Toastify Pro Demo</title> <script src="https://cdn.jsdelivr.net/npm/toastify-pro@latest/dist/toastify-pro.umd.min.js"></script> Success Error Custom<script>
const toast = new ToastifyPro({
position: 'bottom-center',
timeout: 3000
});
function showSuccess() {
toast.success('๐ Hello from Toastify Pro!');
}
function showError() {
toast.error('๐ฅ Something went wrong!');
}
function showCustom() {
toast.show('๐จ Custom notification', 'info', {
timeout: 5000,
allowClose: true
});
}
</script>
```javascript const toast = new ToastifyPro({ position: 'bottom-center', // Toast container position timeout: 3000, // Auto-dismiss time (ms) allowClose: true, // Show close button maxLength: 100 // Maximum message length }); ```
| Position | Description | Best For |
|---|---|---|
top-left |
Top left corner | Desktop apps |
top-center |
Top center | Important alerts |
top-right |
Top right corner | Status updates |
bottom-left |
Bottom left corner | Chat notifications |
bottom-center |
Bottom center (default) | General purpose |
bottom-right |
Bottom right corner | System notifications |
```javascript
// Basic toast types
toast.success(message, options?) // โ
Green success toast
toast.error(message, options?) // โ Red error toast
toast.warning(message, options?) //
// Advanced usage toast.show(message, type, options?) // Custom toast with any type ```
```javascript // Override global settings for individual toasts toast.success('Quick notification', { timeout: 1000, // Show for 1 second allowClose: false, // No close button maxLength: 50 // Shorter message limit });
// Persistent notification (no auto-dismiss) toast.error('Critical error - requires attention', { timeout: 0, // Never auto-dismiss allowClose: true // Must be manually closed });
// Long message with custom settings toast.info('This is a detailed information message that might be longer than usual', { maxLength: 200, // Allow longer message timeout: 8000, // Show for 8 seconds allowClose: true // Allow manual close }); ```
```css /* Override default container positioning */ .toastify-pro-container.bottom-center { bottom: 20px; left: 50%; transform: translateX(-50%); }
/* Custom toast appearance */ .toastify-pro { border-radius: 12px; font-family: 'Inter', -apple-system, sans-serif; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12); backdrop-filter: blur(8px); }
/* Custom success theme */ .toastify-pro.success { background: linear-gradient(135deg, #10b981, #059669); border-left: 4px solid #047857; }
/* Custom animations */ .toastify-pro { animation: slideInUp 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); }
@keyframes slideInUp { from { transform: translateY(100%) scale(0.8); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } } ```
```javascript // Create themed toast instances const successToast = new ToastifyPro({ position: 'top-right', timeout: 2000 });
const errorToast = new ToastifyPro({ position: 'top-center', timeout: 5000, allowClose: true });
// Use for specific scenarios function handleFormSubmit() { try { // ... form logic successToast.success('Form submitted successfully!'); } catch (error) { errorToast.error('Please check your input and try again'); } } ```
| Metric | Toastify Pro | Industry Average |
|---|---|---|
| Bundle Size | ~2KB | ~15KB |
| Init Time | <1ms | ~50ms |
| Animation FPS | 60fps | ~30fps |
| Memory Usage | ~50KB | ~500KB |
| Load Time | <10ms | ~100ms |
| Browser | Version | Status |
|---|---|---|
| Chrome | โฅ 60 | โ Full Support |
| Firefox | โฅ 55 | โ Full Support |
| Safari | โฅ 12 | โ Full Support |
| Edge | โฅ 79 | โ Full Support |
| IE | โฅ 11 |
```javascript const toast = new ToastifyPro({ position: 'top-center' });
function validateForm(formData) { if (!formData.email) { toast.error('๐ง Email is required'); return false; }
if (!formData.password) {
toast.warning('๐ Password cannot be empty');
return false;
}
toast.success('โ
Form validation passed');
return true;
} ```
```javascript const toast = new ToastifyPro({ position: 'bottom-right' });
async function fetchUserData() { try { toast.info('๐ Loading user data...');
const response = await fetch('/api/user');
const data = await response.json();
if (response.ok) {
toast.success('๐ค User data loaded successfully');
return data;
} else {
toast.error('โ Failed to load user data');
}
} catch (error) {
toast.error('๐ Network error occurred');
console.error(error);
}
} ```
```javascript const gameToast = new ToastifyPro({ position: 'top-center', timeout: 2000 });
// Game events
function onPlayerLevelUp(level) {
gameToast.success(๐ Level Up! You reached level ${level});
}
function onPlayerDeath() { gameToast.error('๐ Game Over! Try again'); }
function onAchievementUnlocked(achievement) {
gameToast.info(๐ Achievement Unlocked: ${achievement});
}
```
We โค๏ธ contributions! Here's how you can help make Toastify Pro even better:
Found a bug? Create an issue with:
- Clear description
- Steps to reproduce
- Expected vs actual behavior
- Browser/environment details
Have an idea? Start a discussion about:
- What problem it solves
- How it should work
- Example use cases
```bash
git clone https://github.com/abhipotter/toastify-pro.git cd toastify-pro
npm install
npm run dev
npm test
npm run build
npm run lint ```
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes with tests
- Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
MIT License ยฉ Abhishek Potter
Free for personal and commercial use. See LICENSE for details.
- ๐จ Design inspiration from modern UI libraries
- ๐ Performance optimizations from the community
- ๐ก Feature ideas from user feedback
- โค๏ธ Built with love by developers, for developers
Made with โค๏ธ by Abhishek Potter
Toastify Pro - Because your users deserve beautiful notifications
๐ Try the Live Demo | ๐ Read the Docs | ๐ก See Examples