Carousel of Cards
A nested carousel where multiple card designs cycle in a rotating 3D slot. Hover pauses on the current card with a slight tilt. Clicking advances the carousel, bringing the next card design to the front with a smooth rotation transition.
Carousel of Cards
by FreeCsStyles Dev's
CardsSpin / Rotation / Flip
🌐HTML/CSS🎨Tailwind⚛️React💚Vue🅰️Angular🔥Svelte☁️LWC
#carousel#rotate#card-deck#gallery#cycle#3d#stack#slot#rotation#collection
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/carousel-card.
<iframe src="/embed/carousel-card" sandbox="allow-scripts" loading="lazy" title="Carousel of Cards" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Carousel of Cards, or grab a framework-specific implementation. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.
HTML
<div class="carousel-card">
<div class="carousel-track">
<div class="carousel-item active" style="--i:0">
<div class="carousel-color" style="background:linear-gradient(135deg,#ff6b6b,#ee5a24)"></div>
<div class="carousel-label">Crimson</div>
</div>
<div class="carousel-item" style="--i:1">
<div class="carousel-color" style="background:linear-gradient(135deg,#6bcbff,#0984e3)"></div>
<div class="carousel-label">Ocean</div>
</div>
<div class="carousel-item" style="--i:2">
<div class="carousel-color" style="background:linear-gradient(135deg,#ffd93d,#f0932b)"></div>
<div class="carousel-label">Sunset</div>
</div>
</div>
<div class="carousel-controls">
<div class="carousel-dot active"></div>
<div class="carousel-dot"></div>
<div class="carousel-dot"></div>
</div>
<div class="carousel-content">
<div class="carousel-title">Card Carousel</div>
<div class="carousel-sub">3 Designs</div>
</div>
</div>CSS
.carousel-card { position: relative; width: 220px; min-height: 290px; border-radius: 16px; background: linear-gradient(160deg, #14101a, #0a080e); border: 1.5px solid rgba(150,100,200,0.12); overflow: hidden; cursor: pointer; }
.carousel-card:hover { box-shadow: 0 0 30px rgba(150,100,200,0.08); }
.carousel-track { position: absolute; left: 50%; top: 35%; transform: translate(-50%,-50%) perspective(300px) rotateX(5deg); width: 140px; height: 70px; transform-style: preserve-3d; }
.carousel-item { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: all 0.5s cubic-bezier(0.22,1,0.36,1); opacity: 0.3; transform: translateZ(calc(var(--i) * -20px)) scale(calc(1 - var(--i) * 0.1)); }
.carousel-item.active { opacity: 1; transform: translateZ(10px) scale(1); }
.carousel-card:hover .carousel-item.active { transform: translateZ(20px) scale(1.05); }
.carousel-color { width: 80px; height: 40px; border-radius: 8px; }
.carousel-label { font-size: 10px; color: rgba(255,255,255,0.7); margin-top: 4px; font-weight: 600; }
.carousel-controls { position: absolute; left: 50%; top: 52%; transform: translateX(-50%); display: flex; gap: 6px; }
.carousel-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(150,100,200,0.2); transition: all 0.3s; }
.carousel-dot.active { background: rgba(150,100,200,0.6); width: 16px; border-radius: 3px; }
.carousel-content { position: absolute; inset-x: 0; bottom: 0; padding: 16px; background: linear-gradient(0deg, rgba(0,0,0,0.7), transparent); }
.carousel-title { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.9); }
.carousel-sub { font-size: 9px; color: rgba(150,100,200,0.5); }Tailwind CSS
<div class="group relative w-[220px] min-h-[290px] rounded-2xl bg-gradient-to-b from-[#14101a] to-[#0a080e] border border-purple-500/20 overflow-hidden cursor-pointer group-hover:shadow-[0_0_30px_rgba(150,100,200,0.08)]">
<div class="absolute left-1/2 top-[35%] -translate-x-1/2 -translate-y-1/2 [perspective:300px] [transform:rotateX(5deg)] w-[140px] h-[70px] [transform-style:preserve-3d]">
<div class="absolute inset-0 rounded-xl flex flex-col items-center justify-center opacity-100 z-10 [transform:translateZ(10px)] transition-all group-hover:scale-105 group-hover:[transform:translateZ(20px)]">
<div class="w-20 h-10 rounded-lg bg-gradient-to-br from-red-400 to-red-600"></div>
<p class="text-[10px] text-white/70 mt-1 font-semibold">Crimson</p>
</div> </div>
<div class="absolute left-1/2 top-[52%] -translate-x-1/2 flex gap-1.5">
<div class="w-4 h-1.5 rounded-full bg-purple-500/60"></div>
<div class="w-1.5 h-1.5 rounded-full bg-purple-500/20"></div>
<div class="w-1.5 h-1.5 rounded-full bg-purple-500/20"></div>
</div>
<div class="absolute inset-x-0 bottom-0 p-4 bg-gradient-to-t from-black/70 to-transparent">
<p class="text-sm font-bold text-white/90">Card Carousel</p>
<p class="text-[9px] text-purple-500/50">3 Designs</p>
</div>
</div>React
import React, { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
export function CarouselCard({ width = 220 }) {
const [active, setActive] = useState(0);
const [isHovered, setIsHovered] = useState(false);
const cards = [
{ color: 'linear-gradient(135deg,#ff6b6b,#ee5a24)', label: 'Crimson' },
{ color: 'linear-gradient(135deg,#6bcbff,#0984e3)', label: 'Ocean' },
{ color: 'linear-gradient(135deg,#ffd93d,#f0932b)', label: 'Sunset' },
];
return (
<div onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
<motion.div onClick={() => setActive((a) => (a + 1) % cards.length)} whileTap={{ scale: 0.97 }} className="relative cursor-pointer" style={{ width }}>
<motion.div className="relative rounded-2xl overflow-hidden" style={{ minHeight: 290, background: 'linear-gradient(160deg, #14101a, #0a080e)', border: '1.5px solid rgba(150,100,200,0.12)' }}>
<div className="absolute left-1/2 top-[35%] -translate-x-1/2 -translate-y-1/2" style={{ perspective: 300, transform: 'rotateX(5deg)', width: 140, height: 70, transformStyle: 'preserve-3d' }}>
<AnimatePresence mode="popLayout">
<motion.div key={active} className="absolute inset-0 rounded-xl flex flex-col items-center justify-center"
initial={{ rotateY: -90, opacity: 0 }} animate={{ rotateY: 0, opacity: 1, scale: isHovered ? 1.05 : 1 }}
exit={{ rotateY: 90, opacity: 0 }} transition={{ type: 'spring', stiffness: 200, damping: 20 }}>
<div className="w-20 h-10 rounded-lg" style={{ background: cards[active].color }} />
<p className="text-[10px] font-semibold mt-1" style={{ color: 'rgba(255,255,255,0.7)' }}>{cards[active].label}</p>
</motion.div>
</AnimatePresence>
</div>
<div className="absolute left-1/2 top-[52%] -translate-x-1/2 flex gap-1.5">
{cards.map((_, i) => (
<motion.div key={i} className="h-1.5 rounded-full" style={{ background: i === active ? 'rgba(150,100,200,0.6)' : 'rgba(150,100,200,0.2)' }}
animate={{ width: i === active ? 16 : 6 }} />
))}
</div>
<div className="absolute inset-x-0 bottom-0 p-4" style={{ background: 'linear-gradient(0deg, rgba(0,0,0,0.7), transparent)' }}>
<p className="text-sm font-bold" style={{ color: 'rgba(255,255,255,0.9)' }}>Card Carousel</p>
<p className="text-[9px]" style={{ color: 'rgba(150,100,200,0.5)' }}>{cards.length} Designs</p>
</div>
</motion.div>
</motion.div>
</div>
);
}Where Carousel of Cards fits
- Card Galleries
- Portfolio Showcases
- Product Carousels
- Design Collections
- Rotating Features
Interaction states & animations
- 3D carousel rotation
- Card deck cycling
- Slot advance animation
- Tilt on hover pause
- Stack depth reveal
Topics
- #carousel
- #rotate
- #card-deck
- #gallery
- #cycle
- #3d
- #stack
- #slot
- #rotation
- #collection
Accessibility notes
Carousel rotation may be distracting. prefers-reduced-motion disables auto-rotation. Manual click advance always available. All cards accessible via swipe or button.
Browser support
- Chrome 76+
- Firefox 90+
- Safari 13+
- Edge 79+