Lenticular Flip Card
A lenticular card where the image flips between distinct frames as the user scrolls or tilts their device. Hover locks the animation at the midpoint, showing a blended transitional state between frames. Clicking advances to the next frame manually, making it ideal for before/after comparisons or revealing alternate content versions.
by FreeCsStyles Dev's
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/lenticular-flip-card.
<iframe src="/embed/lenticular-flip-card" sandbox="allow-scripts" loading="lazy" title="Lenticular Flip Card" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Lenticular Flip Card, 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="lenticular-card">
<div class="lenticular-strips"></div>
<div class="lenticular-dots">
<span class="l-dot active"></span>
<span class="l-dot"></span>
<span class="l-dot"></span>
</div>
<div class="lenticular-content">
<div class="l-icon">🌙</div>
<div class="l-bars">
<div class="l-bar" style="height: 40%"></div>
<div class="l-bar" style="height: 55%"></div>
<div class="l-bar" style="height: 48%"></div>
<div class="l-bar" style="height: 62%"></div>
<div class="l-bar" style="height: 50%"></div>
</div>
</div>
<div class="lenticular-footer">
<div><div class="l-title">Before</div><div class="l-sub">Original</div></div>
<div class="l-frame-badge">FRAME 1/3</div>
</div>
</div>CSS
.lenticular-card { position: relative; width: 220px; min-height: 300px; border-radius: 16px; overflow: hidden; background: linear-gradient(160deg, #1a1a2e, #16213e); border: 1.5px solid rgba(74,144,217,0.1); box-shadow: 0 10px 30px rgba(0,0,0,0.3); cursor: pointer; transition: border-color 0.3s ease, box-shadow 0.3s ease; }
.lenticular-card:hover { box-shadow: 0 0 25px rgba(74,144,217,0.08), 0 15px 40px rgba(0,0,0,0.4); border-color: rgba(74,144,217,0.2); }
.lenticular-strips { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.lenticular-strips::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(74,144,217,0.02) 0px, rgba(74,144,217,0.02) 2px, transparent 2px, transparent 12px); }
.lenticular-dots { position: absolute; top: 8%; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; gap: 6px; }
.l-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.1); transition: background 0.3s ease; }
.l-dot.active { background: #4a90d9; }
.lenticular-content { position: absolute; left: 10%; right: 10%; top: 16%; height: 38%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid rgba(74,144,217,0.1); border-radius: 8px; background: rgba(74,144,217,0.04); }
.l-icon { font-size: 24px; }
.l-bars { display: flex; align-items: flex-end; gap: 4px; height: 40px; }
.l-bar { width: 12px; border-radius: 2px 2px 0 0; background: #4a90d9; opacity: 0.4; transition: height 0.5s ease; }
.lenticular-footer { position: absolute; inset-x: 0; bottom: 0; z-index: 10; padding: 20px; background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent); display: flex; justify-content: space-between; align-items: flex-start; }
.l-title { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.9); }
.l-sub { font-size: 9px; color: rgba(74,144,217,0.5); }
.l-frame-badge { padding: 2px 8px; border-radius: 2px; font-size: 7px; font-weight: 700; letter-spacing: 0.1em; background: rgba(74,144,217,0.1); border: 1px solid rgba(74,144,217,0.15); color: #4a90d9; }Tailwind CSS
<div class="group relative w-[220px] min-h-[300px] rounded-2xl overflow-hidden border border-blue-400/20 shadow-lg group-hover:shadow-[0_0_25px_rgba(74,144,217,0.08),0_15px_40px_rgba(0,0,0,0.4)] group-hover:border-blue-400/30 bg-gradient-to-b from-[#1a1a2e] to-[#16213e] cursor-pointer">
<div class="absolute inset-0 z-[2] pointer-events-none" style="background: repeating-linear-gradient(90deg, rgba(74,144,217,0.02) 0px, rgba(74,144,217,0.02) 2px, transparent 2px, transparent 12px);"></div>
<div class="absolute top-[8%] left-1/2 -translate-x-1/2 z-10 flex gap-1.5"><div class="w-1.5 h-1.5 rounded-full bg-blue-400"></div><div class="w-1.5 h-1.5 rounded-full bg-white/10"></div><div class="w-1.5 h-1.5 rounded-full bg-white/10"></div></div>
<div class="absolute left-[10%] right-[10%] top-[16%] h-[38%] flex flex-col items-center justify-center gap-2 rounded-xl border border-blue-400/20 bg-blue-400/5">
<span class="text-2xl">🌙</span>
<div class="flex items-end gap-1 h-10"><div class="w-3 h-[40%] rounded-t-sm bg-blue-400/40"></div><div class="w-3 h-[55%] rounded-t-sm bg-blue-400/40"></div><div class="w-3 h-[48%] rounded-t-sm bg-blue-400/40"></div><div class="w-3 h-[62%] rounded-t-sm bg-blue-400/40"></div><div class="w-3 h-[50%] rounded-t-sm bg-blue-400/40"></div></div>
</div>
<div class="absolute inset-x-0 bottom-0 z-10 p-5 bg-gradient-to-t from-black/60 to-transparent flex items-start justify-between">
<div><p class="text-sm font-bold text-white/90">Before</p><p class="text-[9px] text-blue-400/50">Original</p></div>
<div class="px-2 py-0.5 rounded-sm text-[7px] font-bold tracking-widest bg-blue-400/10 border border-blue-400/20 text-blue-400">FRAME 1/3</div>
</div>
</div>React
import React, { useState, useRef, useCallback, useEffect } from 'react';
import { motion, useMotionValue, useSpring } from 'framer-motion';
export function LenticularFlipCard({ frame1Label = 'Before', width = 220 }) {
const ref = useRef(null);
const [isHovered, setIsHovered] = useState(false);
const [frame, setFrame] = useState(0);
const [isLocked, setIsLocked] = useState(false);
const x = useMotionValue(0);
const y = useMotionValue(0);
const rotateX = useSpring(y, { damping: 25, stiffness: 200 });
const rotateY = useSpring(x, { damping: 25, stiffness: 200 });
const handleMouseMove = (e) => {
if (!ref.current) return;
const rect = ref.current.getBoundingClientRect();
x.set(-((e.clientX - rect.left - rect.width / 2) / (rect.width / 2)) * 6);
y.set(((e.clientY - rect.top - rect.height / 2) / (rect.height / 2)) * 6);
};
const handleClick = () => { setFrame(prev => (prev + 1) % 3); };
useEffect(() => {
if (isLocked || isHovered) return;
const handleScroll = () => {
if (!ref.current || isLocked) return;
const rect = ref.current.getBoundingClientRect();
const progress = 1 - Math.abs(rect.top - window.innerHeight / 2) / (window.innerHeight / 2);
setFrame(Math.max(0, Math.min(2, Math.floor(Math.max(0, Math.min(1, progress)) * 2.99))));
};
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, [isLocked, isHovered]);
useEffect(() => { if (isHovered && !isLocked) setIsLocked(true); }, [isHovered, isLocked]);
const frames = [
{ label: frame1Label, subtitle: 'Original', icon: '🌙', accent: '#4a90d9', bg: 'linear-gradient(160deg, #1a1a2e, #16213e)', value: '47%' },
{ label: 'After', subtitle: 'Enhanced', icon: '☀️', accent: '#f5a623', bg: 'linear-gradient(160deg, #2d1b00, #1a1200)', value: '89%' },
{ label: 'Reveal', subtitle: 'Full Spectrum', icon: '🔍', accent: '#e94560', bg: 'linear-gradient(160deg, #0d1b2a, #1b2838)', value: '100%' },
];
const current = frames[frame];
return (
<div onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => { setIsHovered(false); x.set(0); y.set(0); if (isLocked) setIsLocked(false); }}>
<motion.div ref={ref} onMouseMove={handleMouseMove} onClick={handleClick} style={{ rotateX, rotateY, transformStyle: 'preserve-3d' }} className="relative cursor-pointer">
<motion.div className="relative overflow-hidden rounded-2xl" style={{ width, minHeight: 300, background: current.bg, border: '1.5px solid ' + current.accent + '10' }}
animate={{ boxShadow: isHovered ? '0 0 25px ' + current.accent + '08, 0 15px 40px rgba(0,0,0,0.4)' : '0 10px 30px rgba(0,0,0,0.3)', borderColor: isHovered ? current.accent + '20' : current.accent + '10' }} transition={{ type: 'spring', stiffness: 260, damping: 20 }}>
<div className="absolute inset-0 z-[2] pointer-events-none" style={{ background: 'repeating-linear-gradient(90deg, ' + current.accent + '02 0px, ' + current.accent + '02 2px, transparent 2px, transparent 12px)' }} />
<div className="absolute top-[8%] left-1/2 -translate-x-1/2 z-10 flex gap-1.5">{[0, 1, 2].map(i => <motion.div key={i} className="w-1.5 h-1.5 rounded-full" style={{ background: i === frame ? current.accent : 'rgba(255,255,255,0.1)' }} animate={i === frame ? { scale: [1, 1.3, 1] } : {}} transition={{ duration: 1, repeat: Infinity }} />)}</div>
<motion.div key={frame} className="absolute z-4" style={{ left: '10%', right: '10%', top: '16%', height: '38%' }} initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.3 }}>
<div className="w-full h-full rounded-xl overflow-hidden flex flex-col items-center justify-center gap-2" style={{ border: '1px solid ' + current.accent + '10', background: current.accent + '04' }}>
<span className="text-2xl">{current.icon}</span>
<p className="text-sm font-bold" style={{ color: current.accent }}>{current.value}</p>
</div>
</motion.div>
<div className="absolute inset-x-0 bottom-0 z-10 p-5 bg-gradient-to-t from-black/60 to-transparent">
<div className="flex items-center justify-between mb-2">
<div><p className="text-sm font-bold text-white/90">{isLocked && isHovered ? current.label + ' ⟷ ' + frames[(frame + 1) % 3].label : current.label}</p><p className="text-[9px]" style={{ color: current.accent + '50' }}>{current.subtitle}</p></div>
<div className="px-2 py-0.5 rounded-sm text-[7px] font-bold tracking-widest" style={{ background: current.accent + '10', border: '1px solid ' + current.accent + '15', color: current.accent }}>FRAME {frame + 1}/3</div>
</div>
<div className="text-center"><span className="text-[7px] font-mono" style={{ color: current.accent + '25' }}>{isHovered ? '[▼ click to advance]' : '[▼ scroll or hover to flip]'}</span></div>
</div>
</motion.div>
</motion.div>
</div>
);
}Where Lenticular Flip Card fits
- Before/after comparisons
- Product variant previews
- Alternate content views
- Progressive reveals
- Image galleries
Interaction states & animations
- Frame flip
- Lenticular strip effect
- Scroll-driven animation
- Midpoint blend lock
Topics
- #lenticular
- #flip
- #frame
- #scroll
- #transition
- #before-after
- #blend
- #3d-perspective
- #animation
- #comparison
Accessibility notes
The frame flip relies on scroll position which may not work for all users. Ensure all frames' content is accessible via standard navigation. The hover lock state should not trap keyboard focus. Provide prefers-reduced-motion fallback that shows a static composite view.
Browser support
- Chrome 90+
- Firefox 105+
- Safari 15+
- Edge 90+