Skip to content

Snackbar

A copy-paste toasts & alerts component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Toasts & AlertsHTMLCSSany framework
Message archived

Copy into your project

HTML
<div class="nuda-snackbar" role="status" aria-live="polite">
  <span class="nuda-snackbar__text">Message archived</span>
  <button class="nuda-snackbar__action">Undo</button>
  <div class="nuda-snackbar__progress"></div>
</div>
CSS
/* Snackbar
   Bottom snackbar with progress timer and action button.
   Customize: --snackbar-accent, --snackbar-bg, --snackbar-duration */

.nuda-snackbar {
  --snackbar-accent: #e4ff54;
  --snackbar-bg: #1a1a1a;
  --snackbar-duration: 4s;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--snackbar-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  min-width: 260px;
  position: relative;
  overflow: hidden;
  animation: nuda-snackbar-up 0.3s ease-out;
}

.nuda-snackbar__text {
  color: #ccc;
  font-size: 0.85rem;
  flex: 1;
}

.nuda-snackbar__action {
  background: none;
  border: none;
  color: var(--snackbar-accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.nuda-snackbar__action:hover {
  text-decoration: underline;
}

.nuda-snackbar__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--snackbar-accent);
  animation: nuda-snackbar-progress var(--snackbar-duration) linear forwards;
}

@keyframes nuda-snackbar-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nuda-snackbar-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .nuda-snackbar {
    animation: none;
  }
  .nuda-snackbar__progress {
    animation: none;
    width: 100%;
  }
}

How to use Snackbar

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More toasts & alerts components

← Browse all NudaUI components