Back to library
INTERACTION_117

Animated Mobile Menu.

The panel slides in and links cascade behind it. The panel translated off-canvas, links 12px down at 0 opacity before the trigger; sliding the panel in, then cascading the links once tapping the menu button.

CATEGORY
Navigation
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Mobile
PERFORMANCE
Light
LIVE PLAYGROUND
Home
Work
Pricing
CSS / CSS
/* Animated Mobile Menu — The panel slides in and links cascade behind it. */
.animated-mobile-menu {
  --dur: 420ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 55ms;
  will-change: transform, opacity;
}

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

/* the panel translated off-canvas, links 12px down at 0 opacity -> sliding the panel in, then cascading the links */
@keyframes animated-mobile-menu-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Animated Mobile Menu — trigger: tapping the menu button */
export function AnimatedMobileMenu({ 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="animated-mobile-menu" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

Vault/Text/Blur
INTERACTION_126CSS

Animated Breadcrumbs

Breadcrumb segments slide in as the path deepens.

Navigation / LightView
DISCOVEREFFECTSPROMPTS
INTERACTION_027CSS

Navigation Underline

Underline grows from the origin side on hover.

Navigation / LightView
HomeWorkPricing
INTERACTION_119CSS

Expanding Navigation Pill

A pill indicator glides between nav items.

Navigation / LightView
HomeWorkPricing
INTERACTION_120CSS

Active Link Indicator

A rule wipes in under the hovered link and stays on the active route.

Navigation / LightView