← Prompt Lab

3D Coverflow Carousel

Pure CSS view(inline) + Scroll Snap for E-Commerce, Travel & Embla
E-Commerce · Scroll 3D1.2 KB CSS0 copies
SHARE
06 / PLAYGROUND3D Coverflow Carousel
BRAND COLORS
Fullscreen ↗

A silky Apple/Aesop-grade horizontal 3D Coverflow carousel where side cards rotate inward along Y-axis perspective as you swipe — replacing heavy Swiper/GSAP 3D sliders with ~25 lines of native CSS view(inline) and scroll-snap.

CSS view(inline)Coverflow 3DEmbla / shadcn0 KB Scroll JS
/* 1) Paste once in globals.css (works standalone or inside shadcn/ui Carousel / Embla — 0 KB scroll JS)
@keyframes cf-turn {
  0%   { opacity: 0.42; z-index: 1;  transform: perspective(900px) translateX(-22px) rotateY(-46deg) scale(0.82); }
  32%  { opacity: 0.90; z-index: 4;  transform: perspective(900px) translateX(-4px)  rotateY(-24deg) scale(0.92); }
  50%  { opacity: 1;    z-index: 12; transform: perspective(900px) translateX(0)     rotateY(0deg)   scale(1.04); }
  68%  { opacity: 0.90; z-index: 4;  transform: perspective(900px) translateX(4px)   rotateY(24deg)  scale(0.92); }
  100% { opacity: 0.42; z-index: 1;  transform: perspective(900px) translateX(22px)  rotateY(46deg)  scale(0.82); }
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .cf-slide { view-timeline-name: --cf-slide; view-timeline-axis: inline; }
    .cf-card {
      animation: cf-turn linear both;
      animation-timeline: --cf-slide;
      animation-range: cover 0% cover 100%;
    }
  }
}
*/

// 2) Drop-in React + Tailwind 3D Coverflow Carousel (replaces Swiper 3D JS)
'use client'
import { useRef } from 'react'

export interface CoverflowItem {
  id: string
  tag: string
  title: string
  subtitle: string
  meta: string
  imageSrc?: string
}

const DEMO_ITEMS: CoverflowItem[] = [
  { id: '1', tag: 'TITANIUM', title: 'Chrono Field 38mm', subtitle: 'Brushed Grade-5 Titanium', meta: '$680' },
  { id: '2', tag: 'PARFUM', title: 'Cedar & Fig N°09', subtitle: 'Hand-blown Amber Glass', meta: '$240' },
  { id: '3', tag: 'FLAGSHIP', title: 'Atelier Acoustic One', subtitle: 'Anodized Spatial Speaker', meta: '$420' },
  { id: '4', tag: 'STUDIO', title: 'Reference Air Pro', subtitle: 'Lambskin · 42h Battery', meta: '$540' },
  { id: '5', tag: 'LIGHTING', title: 'Solstice Desk Lamp', subtitle: '2700K Opal Glass · Brass', meta: '$310' },
]

export function CoverflowCarousel({ items = DEMO_ITEMS }: { items?: CoverflowItem[] }) {
  const trackRef = useRef<HTMLDivElement>(null)

  const scrollToSlide = (idx: number) => {
    const slides = trackRef.current?.querySelectorAll<HTMLElement>('[data-cf-slide]')
    slides?.[idx]?.scrollIntoView({ inline: 'center', block: 'nearest', behavior: 'smooth' })
  }

  return (
    <div className="relative w-full overflow-hidden rounded-3xl border border-stone-200 bg-[#f4efe7] py-8 dark:border-white/10 dark:bg-[#080b12]">
      <div
        ref={trackRef}
        className="flex snap-x snap-mandatory gap-4 overflow-x-auto scroll-smooth px-[calc(50%-118px)] py-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
      >
        {items.map((item, idx) => (
          <div key={item.id} data-cf-slide className="cf-slide w-[236px] shrink-0 snap-center">
            <article
              onClick={() => scrollToSlide(idx)}
              className="cf-card relative flex h-[316px] cursor-pointer flex-col overflow-hidden rounded-2xl border border-stone-200/80 bg-white shadow-xl dark:border-white/10 dark:bg-[#121724]"
            >
              <div
                className="relative m-2.5 h-44 rounded-xl"
                style={{ background: `linear-gradient(135deg, #c87d3233, #0f766e33)` }}
              >
                {item.imageSrc && (
                  <img src={item.imageSrc} alt={item.title} className="h-full w-full rounded-xl object-cover" />
                )}
                <span className="absolute left-2.5 top-2.5 rounded-full bg-slate-950/65 px-2.5 py-1 font-mono text-[10px] font-semibold text-white backdrop-blur">
                  {item.tag}
                </span>
              </div>
              <div className="flex flex-1 flex-col justify-between px-3.5 pb-3.5 pt-1">
                <div>
                  <h3 className="truncate text-sm font-semibold text-stone-900 dark:text-white">{item.title}</h3>
                  <p className="truncate text-xs text-stone-500 dark:text-slate-400">{item.subtitle}</p>
                </div>
                <div className="flex items-center justify-between border-t border-stone-200/70 pt-2.5 dark:border-white/10">
                  <span className="font-mono text-xs font-semibold text-stone-900 dark:text-white">{item.meta}</span>
                  <span
                    className="rounded-full px-2.5 py-1 font-mono text-[10px] font-semibold text-white"
                    style={{ background: `linear-gradient(135deg, #c87d32, #0f766e)` }}
                  >
                    Inspect →
                  </span>
                </div>
              </div>
            </article>
          </div>
        ))}
      </div>
    </div>
  )
}

WHY THIS WORKS IN PRODUCTION

  • Pure CSS view-timeline-axis: inline + scroll-snap — replaces heavy 40 KB Swiper 3D JS bundles
  • Live multi-vertical preview: E-Commerce Lookbook, Travel Destinations & Portfolio Case Studies
  • Click any angled side card, swipe on mobile touch, press ←/→, or adjust 28°/46°/64° curve angle
  • Drop-in CSS utility works standalone or layered onto shadcn/ui Carousel (Embla) with @supports fallback

DROP-IN SPECS // WEB & MOBILE FIT

UI SLOTScroll & 3D CSS
BEST USE CASEE-Commerce Lookbook Galleries, Travel Destination Sliders & Creative Portfolios
IDEAL PLACEMENTProduct Detail Showcase, Featured Collection Strip or Hero Case Study Slider
BUNDLE SIZE1.2 KB CSS
DEPENDENCIESZero (CSS view(inline) · Embla/shadcn ready)
MOBILE / TOUCHNative Momentum Swipe + Snap
GPU WEIGHTLight · 60fps