Back to library
INTERACTION_091

Button Success Animation.

A check mark draws itself once the action completes. The label or spinner visible before the trigger; swapping to a check mark whose stroke draws over 260ms, then restoring the label after 1.4s once a successful response.

CATEGORY
Buttons
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
CSS / CSS
/* Button Success Animation — A check mark draws itself once the action completes. */
.button-success-animation {
  --dur: 260ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

.button-success-animation > * {
  opacity: 0;
  transform: translateY(14px);
  animation: button-success-animation-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* the label or spinner visible -> swapping to a check mark whose stroke draws over 260ms, then restoring the label after 1.4s */
@keyframes button-success-animation-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button-success-animation > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Button Success Animation — trigger: a successful response */
export function ButtonSuccessAnimation({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="button-success-animation" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_082CSS

Liquid Hover Button

A rounded fill rises from the bottom edge and floods the button.

Buttons / LightView
INTERACTION_084CSS + JS

Cursor Following Glow Button

A soft glow tracks the pointer inside the button surface.

Buttons / LightView
INTERACTION_085CSS

Sliding Label Button

The label slides up and a duplicate takes its place.

Buttons / LightView
INTERACTION_086CSS

Arrow Morph Button

The arrow exits right and re-enters from the left on hover.

Buttons / LightView