Back to library
INTERACTION_123

Floating Dock.

Dock icons scale with pointer proximity like a desktop dock. All icons at equal size before the trigger; scaling each icon by its distance from the pointer with a smooth falloff once pointer movement along the dock.

CATEGORY
Navigation
COMPLEXITY
Intermediate
TECH
CSS + JS
PLATFORM
Desktop
PERFORMANCE
Light
LIVE PLAYGROUND
CSS / CSS
/* Floating Dock — Dock icons scale with pointer proximity like a desktop dock. */
.floating-dock {
  --dur: 240ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

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

/* all icons at equal size -> scaling each icon by its distance from the pointer with a smooth falloff */
@keyframes floating-dock-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Floating Dock — trigger: pointer movement along the dock */
export function FloatingDock({ 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="floating-dock" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

Home
Work
Pricing
INTERACTION_118CSS

Fullscreen Navigation Reveal

A full-screen overlay wipes down and oversized links rise in.

Navigation / LightView
HomeWorkPricing
INTERACTION_124CSS

Mega Menu Reveal

A wide panel drops open with its columns cascading.

Navigation / LightView
DISCOVEREFFECTSPROMPTS
INTERACTION_027CSS

Navigation Underline

Underline grows from the origin side on hover.

Navigation / LightView
Home
Work
Pricing
INTERACTION_117CSS

Animated Mobile Menu

The panel slides in and links cascade behind it.

Navigation / LightView