AI CSS Animations

Saved to Memory Toast

A toast that springs up to say Saved to memory: the bookmark draws and fills with a sparkle burst, then prefers pnpm over npm writes itself in and the pnpm chip glints before the toast drops away.

Also known as: ai memory updated notification, agent remembers preference, memory saved animation.

Saved to memory Prefers pnpm over npm

HTML

<div class="aia-memory-saved-toast" role="status" aria-label="Saved to memory: prefers pnpm over npm">
  <div class="aia-memory-saved-toast-box">
    <span class="aia-memory-saved-toast-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 3.5h9a1 1 0 0 1 1 1V21L12 17l-5.5 4V4.5a1 1 0 0 1 1-1z"/></svg><i></i><i></i><i></i><i></i></span>
    <span class="aia-memory-saved-toast-text">
      <b>Saved to memory</b>
      <span class="aia-memory-saved-toast-line">Prefers <code>pnpm</code> over <code>npm</code></span>
    </span>
    <span class="aia-memory-saved-toast-manage" aria-hidden="true">Manage</span>
  </div>
</div>

CSS

.aia-memory-saved-toast {
  --c: var(--aia-color, #7c5cff);
  font-size: var(--aia-size, 16px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
  --d: 6s;
  display: grid;
  place-items: center;
  height: 5.5em;
}
.aia-memory-saved-toast-box {
  display: flex;
  align-items: center;
  gap: 0.75em;
  width: 20em;
  box-sizing: border-box;
  padding: 0.7em 0.85em 0.7em 0.7em;
  border-radius: 0.95em;
  background: color-mix(in srgb, currentColor 4%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 11%, transparent), 0 0.2em 0.4em color-mix(in srgb, currentColor 4%, transparent), 0 1.2em 2.4em -1.2em rgb(0 0 0 / 0.4);
  animation: aia-memory-saved-toast-enter var(--d) cubic-bezier(0.34, 1.4, 0.64, 1) infinite;
}
.aia-memory-saved-toast-icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.3em;
  height: 2.3em;
  border-radius: 0.7em;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
}
.aia-memory-saved-toast-icon svg {
  width: 1.25em;
  height: 1.25em;
  stroke-dasharray: 52;
  animation: aia-memory-saved-toast-mark var(--d) ease infinite;
}
/* four sparks that burst from the bookmark as it fills */
.aia-memory-saved-toast-icon i {
  --a: 0deg;
  position: absolute;
  left: calc(50% - 0.12em);
  top: calc(50% - 0.12em);
  width: 0.24em;
  height: 0.24em;
  border-radius: 50%;
  background: var(--c);
  opacity: 0;
  animation: aia-memory-saved-toast-spark var(--d) cubic-bezier(0.2, 0.7, 0.3, 1) infinite;
}
.aia-memory-saved-toast-icon i:nth-of-type(2) { --a: 90deg; }
.aia-memory-saved-toast-icon i:nth-of-type(3) { --a: 180deg; }
.aia-memory-saved-toast-icon i:nth-of-type(4) { --a: 270deg; }
.aia-memory-saved-toast-text {
  display: grid;
  gap: 0.15em;
  min-width: 0;
  margin-right: auto;
}
.aia-memory-saved-toast-text b {
  font-size: 0.88em;
  font-weight: 600;
}
.aia-memory-saved-toast-line {
  color: color-mix(in srgb, currentColor 65%, transparent);
  font-size: 0.8em;
  white-space: nowrap;
  animation: aia-memory-saved-toast-write var(--d) cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.aia-memory-saved-toast-line code {
  padding: 0.05em 0.35em;
  border-radius: 0.3em;
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: currentColor;
  font: 500 0.92em ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
.aia-memory-saved-toast-line code:first-child {
  background: color-mix(in srgb, var(--c) 16%, transparent) linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.65) 50%, transparent 70%) 0 0 / 250% 100% no-repeat;
  color: color-mix(in srgb, var(--c) 80%, currentColor);
  font-weight: 600;
  animation: aia-memory-saved-toast-glint var(--d) ease infinite;
}
.aia-memory-saved-toast-manage {
  flex: none;
  padding: 0.35em 0.65em;
  border-radius: 0.5em;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 14%, transparent);
  color: color-mix(in srgb, currentColor 70%, transparent);
  font-size: 0.72em;
  font-weight: 600;
}
@keyframes aia-memory-saved-toast-enter {
  0% { opacity: 0; transform: translateY(1.4em) scale(0.94); filter: blur(0.2em); }
  9%, 86% { opacity: 1; transform: none; filter: blur(0); }
  93%, 100% { opacity: 0; transform: translateY(0.8em) scale(0.97); filter: blur(0.15em); animation-timing-function: ease-in; }
}
@keyframes aia-memory-saved-toast-mark {
  0%, 8% { stroke-dashoffset: 52; fill: transparent; }
  20% { stroke-dashoffset: 0; fill: transparent; }
  26%, 100% { stroke-dashoffset: 0; fill: currentColor; }
}
@keyframes aia-memory-saved-toast-spark {
  0%, 24% { opacity: 0; transform: rotate(var(--a)) translateY(0) scale(0.5); }
  26% { opacity: 1; transform: rotate(var(--a)) translateY(-0.7em) scale(1); }
  36%, 100% { opacity: 0; transform: rotate(var(--a)) translateY(-1.5em) scale(0.3); }
}
@keyframes aia-memory-saved-toast-write {
  0%, 22% { clip-path: inset(0 100% 0 0); opacity: 0.4; }
  44%, 100% { clip-path: inset(0 0 0 0); opacity: 1; }
}
@keyframes aia-memory-saved-toast-glint {
  0%, 46% { background-position: 150% 0; }
  58%, 100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .aia-memory-saved-toast *,
  .aia-memory-saved-toast *::before {
    animation-play-state: paused;
    animation-delay: calc(var(--d) * -0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .aia-memory-saved-toast, .aia-memory-saved-toast *, .aia-memory-saved-toast::before, .aia-memory-saved-toast::after, .aia-memory-saved-toast *::before, .aia-memory-saved-toast *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --aia-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --aia-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar ai animations