UNPKG

toastvibe

Version:

ToastVibe is a lightweight, customizable, and flexible toast notification library for React.

241 lines (206 loc) 4.66 kB
/* Base Toast Styles */ .toast { padding: 12px 20px; border-radius: 8px; color: white; font-size: 14px; font-family: Arial, sans-serif; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); margin: 8px; display: flex; align-items: center; justify-content: space-between; max-width: 300px; animation: fadeIn 0.3s ease-in-out; background: linear-gradient(135deg, #3498db, #2980b9); /* Default gradient */ transition: transform 0.3s ease, opacity 0.3s ease, background 0.5s ease; } .toast:hover { transform: translateY(-2px); /* Slight lift on hover */ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); /* Enhanced shadow on hover */ } /* Toast Types */ .toast-pending { background: linear-gradient(135deg, #3498db, #2980b9); /* Gradient for pending toasts */ } .toast-success { background: linear-gradient(135deg, #2ecc71, #27ae60); /* Gradient for success toasts */ } .toast-warning { background: linear-gradient(135deg, #f1c40f, #f39c12); /* Gradient for warning toasts */ } .toast-error { background: linear-gradient(135deg, #e74c3c, #c0392b); /* Gradient for error toasts */ } /* Rich Colors */ .toast.rich-colors { animation: colorChange 2s infinite alternate; } @keyframes colorChange { 0% { background: linear-gradient(135deg, var(--toast-color), var(--toast-color-dark)); } 100% { background: linear-gradient(135deg, var(--toast-color-dark), var(--toast-color)); } } .toast-pending.rich-colors { --toast-color: #3498db; --toast-color-dark: #2980b9; } .toast-success.rich-colors { --toast-color: #2ecc71; --toast-color-dark: #27ae60; } .toast-warning.rich-colors { --toast-color: #f1c40f; --toast-color-dark: #f39c12; } .toast-error.rich-colors { --toast-color: #e74c3c; --toast-color-dark: #c0392b; } /* Close Button */ .toast-close { background: none; border: none; color: white; cursor: pointer; margin-left: 10px; font-size: 16px; font-weight: bold; transition: opacity 0.2s ease; } .toast-close:hover { opacity: 0.8; } /* Toast Container */ .toast-container { position: fixed !important; z-index: 9999 !important; } .toast-container.top-left { top: 20px; left: 20px; } .toast-container.top-right { top: 20px; right: 20px; } .toast-container.bottom-left { bottom: 20px; left: 20px; } .toast-container.bottom-right { bottom: 20px; right: 20px; } .toast-container.top-center { top: 20px; left: 50%; transform: translateX(-50%); } .toast-container.bottom-center { bottom: 20px; left: 50%; transform: translateX(-50%); } .toast-container.center { top: 50%; left: 50%; transform: translate(-50%, -50%); } /* Animations */ @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } /* Position-Based Text Animations */ .toast-container.top-left .toast { animation: slideInLeft 0.5s ease-in-out; } .toast-container.top-right .toast { animation: slideInRight 0.5s ease-in-out; } .toast-container.top-center .toast { animation: slideInTop 0.5s ease-in-out; } .toast-container.bottom-center .toast { animation: slideInBottom 0.5s ease-in-out; } @keyframes slideInLeft { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideInTop { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes slideInBottom { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } /* Loading Spinner */ .toast-loading { display: flex; align-items: center; margin-left: 10px; } .toast-loading-spinner { border: 2px solid rgba(255, 255, 255, 0.3); border-top: 2px solid white; border-radius: 50%; width: 16px; height: 16px; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } /* Toast Message */ .toast-message { flex: 1; /* Ensures the message takes up available space */ margin-right: 10px; /* Adds spacing between message and close button */ } /* Toast Icon */ .toast-icon { margin-right: 10px; /* Adds spacing between icon and message */ font-size: 18px; /* Adjust icon size */ }