Skip to content

Instantly share code, notes, and snippets.

@VitalyErmilov
Created May 13, 2025 17:42
Show Gist options
  • Select an option

  • Save VitalyErmilov/44def1e71499f075057fba26c13cbec9 to your computer and use it in GitHub Desktop.

Select an option

Save VitalyErmilov/44def1e71499f075057fba26c13cbec9 to your computer and use it in GitHub Desktop.
Toast Notification Playground πŸžπŸ””
<div class="playground">
<div class="header-image">
<img src="http://mattcannon.games/codepen/toast/tt.png" alt="Toast Notification Playground">
</div>
<div class="section">
<h3><i class="fa-solid fa-palette"></i> Theme</h3>
<div class="grid" id="theme-buttons">
<button data-theme="arcade" class="modern-btn"><i class="fa-solid fa-gamepad"></i> Arcade</button>
<button data-theme="professional" class="modern-btn"><i class="fa-solid fa-briefcase"></i> Professional</button>
<button data-theme="brutalist" class="modern-btn"><i class="fa-solid fa-cube"></i> Brutalist</button>
<button data-theme="glass" class="modern-btn"><i class="fa-solid fa-wine-glass"></i> Glass</button>
<button data-theme="neon" class="modern-btn"><i class="fa-solid fa-bolt-lightning"></i> Neon</button>
</div>
</div>
<div class="section">
<h3><i class="fa-solid fa-bolt"></i> Animation</h3>
<div class="grid" id="animation-buttons">
<button data-animation="slide" class="modern-btn"><i class="fa-solid fa-arrow-up"></i> Slide</button>
<button data-animation="bounce" class="modern-btn"><i class="fa-solid fa-arrows-rotate"></i> Bounce</button>
<button data-animation="fade" class="modern-btn"><i class="fa-solid fa-water"></i> Fade</button>
<button data-animation="flip" class="modern-btn"><i class="fa-solid fa-retweet"></i> Flip</button>
<button data-animation="zoom" class="modern-btn"><i class="fa-solid fa-magnifying-glass-plus"></i> Zoom</button>
</div>
</div>
<div class="btn-wrap">
<button class="launch-btn" onclick="showToast()">
<i class="fa-solid fa-bread-slice"></i> Let's Get Toasted
</button>
</div>
<div id="toast-container"></div>
</div>
let selectedTheme = "arcade";
let selectedAnimation = "slide";
const themeIcons = {
arcade: "fa-gamepad",
professional: "fa-briefcase",
brutalist: "fa-cube",
glass: "fa-wine-glass",
neon: "fa-bolt-lightning"
};
document.querySelectorAll("#theme-buttons .modern-btn").forEach((btn) => {
btn.addEventListener("click", () => {
selectedTheme = btn.getAttribute("data-theme");
document
.querySelectorAll("#theme-buttons .modern-btn")
.forEach((b) => b.classList.remove("active"));
btn.classList.add("active");
});
});
document.querySelectorAll("#animation-buttons .modern-btn").forEach((btn) => {
btn.addEventListener("click", () => {
selectedAnimation = btn.getAttribute("data-animation");
document
.querySelectorAll("#animation-buttons .modern-btn")
.forEach((b) => b.classList.remove("active"));
btn.classList.add("active");
});
});
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function showToast() {
const container = document.getElementById("toast-container");
const toast = document.createElement("div");
toast.className = `toast ${selectedTheme}`;
const icon = document.createElement("i");
icon.className = `fa-solid ${themeIcons[selectedTheme] || "fa-bread-slice"}`;
const text = document.createElement("span");
text.textContent = `This is a ${capitalize(
selectedTheme
)} toast in ${capitalize(selectedAnimation)} style.`;
const glow = document.createElement("div");
glow.className = "toast-glow";
if (selectedTheme === "neon") {
glow.style.background =
"radial-gradient(circle, rgba(0,255,0,0.25), transparent 70%)";
} else if (selectedTheme === "brutalist") {
glow.style.background =
"radial-gradient(circle, rgba(255,255,255,0.2), transparent 70%)";
} else if (selectedTheme === "glass") {
glow.style.background =
"radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%)";
}
toast.appendChild(icon);
toast.appendChild(text);
toast.appendChild(glow);
container.appendChild(toast);
const easing =
selectedAnimation === "bounce"
? "cubic-bezier(0.25, 1.5, 0.5, 1)"
: "ease-out";
if (selectedTheme === "glass" && selectedAnimation === "zoom") {
toast.style.animationName = "zoom-glass";
} else {
toast.style.animationName = selectedAnimation;
}
toast.style.animationDuration = "0.6s";
toast.style.animationTimingFunction = easing;
toast.style.animationFillMode = "both";
setTimeout(() => toast.remove(), 7000);
}
:root {
--title: "Toast Notification Showcase";
--author: "Matt Cannon";
--contact: "mc@mattcannon.design";
--description: "A stylish interactive showcase where you can mix and match themes and animations to preview toast notifications in real time.";
--keywords: "toast, notification, snackbar, animation, css effects, frosted glass, UI showcase, frontend demo, javascript, css, codepen";
--last-modified: "2025-05-12";
--content-language: "en";
--generator: "HTML5, CSS3, JavaScript, Font Awesome, Google Fonts";
}
body {
font-family: "Rubik", sans-serif;
background: #222325;
color: white;
margin: 0;
padding: 3rem 2rem;
}
.playground {
max-width: 880px;
margin: auto;
}
.header-image {
width: 100%;
max-width: 640px;
margin: 0 auto 1.5rem;
display: flex;
justify-content: center;
align-items: center;
}
.header-image img {
width: 100%;
height: auto;
max-height: 200px;
object-fit: contain;
display: block;
}
.section {
margin-bottom: 2.8rem;
}
h3 {
font-size: 1rem;
font-weight: 600;
margin-bottom: 1.25rem;
color: #aaa;
text-transform: uppercase;
letter-spacing: 0.5px;
border-bottom: 1px solid #333;
padding-bottom: 0.5rem;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 1rem;
}
.modern-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
font-size: 0.95rem;
padding: 0.75rem 1rem;
background: #2a2b2c;
border: 1.5px solid #444;
border-radius: 10px;
color: white;
cursor: pointer;
transition: all 0.2s ease;
font-family: "Rubik", sans-serif;
}
.modern-btn i {
font-size: 1.1rem;
}
.modern-btn:hover {
background: #333;
border-color: #666;
}
.modern-btn.active {
border-color: #0ff;
box-shadow: 0 0 8px #0ff;
background: #2a2b2c;
}
.btn-wrap {
display: flex;
justify-content: center;
margin-top: 4rem;
}
.launch-btn {
display: inline-flex;
align-items: center;
gap: 0.6rem;
padding: 1rem 2.5rem;
font-size: 1rem;
font-weight: 600;
border: 2px solid white;
background: transparent;
color: white;
border-radius: 999px;
cursor: pointer;
transition: 0.2s ease;
font-family: "Rubik", sans-serif;
}
.launch-btn:hover {
background: white;
color: #222325;
}
#toast-container {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 1rem;
}
.toast {
position: relative;
display: flex;
align-items: center;
gap: 0.9rem;
padding: 1rem 1.4rem;
border-radius: 10px;
font-size: 0.95rem;
line-height: 1.4;
max-width: 320px;
background: #333;
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
opacity: 1;
animation-fill-mode: both;
backdrop-filter: blur(4px);
font-family: "Rubik", sans-serif;
overflow: hidden;
}
.toast i {
font-size: 1.3rem;
flex-shrink: 0;
}
.toast-glow {
position: absolute;
inset: -20px;
border-radius: 20px;
background: radial-gradient(circle, rgba(0, 255, 255, 0.2), transparent 70%);
pointer-events: none;
filter: blur(16px);
z-index: -1;
}
.arcade {
background: #0ff;
color: #000;
font-family: "Press Start 2P", monospace;
}
.professional {
background: #2e2e2e;
color: #eee;
}
.brutalist {
background: #fff;
color: #000;
font-family: monospace;
border: 2px solid #000;
}
.glass {
background: rgba(255, 255, 255, 0.15);
color: white;
border: 1px solid rgba(255, 255, 255, 0.25);
backdrop-filter: blur(20px) saturate(160%);
-webkit-backdrop-filter: blur(20px) saturate(160%);
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}
.neon {
background: #111;
color: #0f0;
border: 1.5px solid #0f0;
text-shadow: 0 0 4px #0f0;
box-shadow: 0 0 6px rgba(0, 255, 0, 0.15), 0 0 12px rgba(0, 255, 0, 0.1);
}
@keyframes slide {
0% {
opacity: 0;
transform: translateY(40px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fade {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes bounce {
0% {
transform: translateY(100%);
opacity: 0;
}
40% {
transform: translateY(-20%);
opacity: 1;
}
60% {
transform: translateY(10%);
}
80% {
transform: translateY(-4%);
}
100% {
transform: translateY(0);
}
}
@keyframes zoom {
0% {
transform: scale(0.4);
opacity: 0;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.toast.glass {
animation-name: zoom-glass !important;
}
@keyframes zoom-glass {
0% {
transform: scale(0.4);
opacity: 0;
}
100% {
transform: scale(1);
opacity: 1;
}
}
@keyframes flip {
0% {
transform: rotateX(90deg);
opacity: 0;
}
100% {
transform: rotateX(0deg);
opacity: 1;
}
}
<link href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;600&amp;display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&amp;display=swap" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" rel="stylesheet" />

Toast Notification Playground πŸžπŸ””

A stylish interactive showcase where you can mix and match themes and animations to preview toast notifications in real time.

A Pen by Matt Cannon on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment