Glassmorphism Toast Notification - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Glassmorphism Toast Notification</title> <style> body { font-family: Arial, sans-serif; background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; overflow: hidden; } .toast-container { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; } .toast { display: flex; align-items: center; padding: 15px; min-width: 300px; background: rgba(255, 255, 255, 0.1); border-radius: 15px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); animation: slideInRight 0.5s, fadeOut 0.5s 3.5s; } .toast-icon { font-size: 24px; margin-right: 15px; animation: rotateIn 1s; } .toast-content { flex-grow: 1; } .toast-content h4 { margin: 0; font-size: 18px; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .toast-content p { margin: 5px 0 0; color: #fff; } @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } } @keyframes rotateIn { from { transform: rotate(-200deg); opacity: 0; } to { transform: rotate(0); opacity: 1; } } </style> </head> <body> <div class="toast-container" id="toast-container"></div> <script> function showToast(title, message, icon) { const toastContainer = document.getElementById('toast-container'); const toast = document.createElement('div'); toast.className = 'toast'; const toastIcon = document.createElement('div'); toastIcon.className = 'toast-icon'; toastIcon.innerHTML = icon; const toastContent = document.createElement('div'); toastContent.className = 'toast-content'; const toastTitle = document.createElement('h4'); toastTitle.innerText = title; const toastMessage = document.createElement('p'); toastMessage.innerText = message; toastContent.appendChild(toastTitle); toastContent.appendChild(toastMessage); toast.appendChild(toastIcon); toast.appendChild(toastContent); toastContainer.appendChild(toast); setTimeout(() => { toast.remove(); }, 4000); } // Example usage showToast('Success', 'Your action was successful!', 'â '); showToast('Error', 'Something went wrong.', 'â'); showToast('Info', 'Here is some information for you.', 'âšī¸'); </script> </body> </html>