Gravity Card
A card that behaves as if it exists in real gravity. Features physics-based weight, momentum, drag interaction, bounce on click, and dust particles. The card feels heavy with realistic contact shadows and spring physics.
Gravity Card
by FreeCsStyles Dev's
CardsGravity / Physics
🌐HTML/CSS🎨Tailwind⚛️React💚Vue🅰️Angular🔥Svelte☁️LWC
#gravity#physics#weight#heavy#drag#bounce#momentum#spring#mass#realistic
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/gravity-card.
<iframe src="/embed/gravity-card" sandbox="allow-scripts" loading="lazy" title="Gravity Card" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Gravity 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="gravity-card" draggable="true">
<div class="gravity-contact-shadow"></div>
<div class="gravity-frame">
<div class="gravity-texture"></div>
<div class="gravity-content">
<div class="gravity-header">
<span class="gravity-label">Heavy Metal Dashboard</span>
<div class="gravity-divider"></div>
</div>
<div class="gravity-metric">
<div class="gravity-value">847 kg</div>
<div class="gravity-unit">Total Load</div>
</div>
<div class="gravity-divider"></div>
<div class="gravity-row">
<span class="gravity-row-label">Max Capacity</span>
<span class="gravity-row-value">1,200 kg</span>
</div>
<div class="gravity-weight">
<div class="gravity-weight-h">
<span>WEIGHT</span>
<span>75 kg</span>
</div>
<div class="gravity-weight-track">
<div class="gravity-weight-fill" style="width: 75%"></div>
</div>
</div>
<div class="gravity-status">
<div class="gravity-dot"></div>
<span>GROUNDED</span>
</div>
</div>
</div>
</div>CSS
.gravity-card {
position: relative;
width: 210px;
}
.gravity-contact-shadow {
position: absolute;
bottom: -16px;
left: 5%;
right: 5%;
height: 24px;
border-radius: 50%;
background: radial-gradient(ellipse, rgba(0,0,0,0.3), transparent);
filter: blur(8px);
pointer-events: none;
z-index: -1;
}
.gravity-frame {
position: relative;
border-radius: 12px;
overflow: hidden;
min-height: 290px;
background: linear-gradient(160deg, #2a2722, #1a1814, #0f0d0a);
border: 1.5px solid rgba(180,160,140,0.15);
box-shadow: 0 20px 50px rgba(0,0,0,0.5);
transition: all 0.4s ease;
cursor: grab;
}
.gravity-frame:active {
cursor: grabbing;
transform: scale(0.98);
}
.gravity-texture {
position: absolute;
inset: 0;
opacity: 0.03;
pointer-events: none;
background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1h1v1H1V1zm2 2h1v1H3V3z' fill='%23ffffff' fill-opacity='0.5'/%3E%3C/svg%3E");
}
.gravity-content {
position: relative;
z-index: 10;
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
}
.gravity-header {}
.gravity-label {
font-size: 11px;
font-weight: 600;
letter-spacing: 0.05em;
color: rgba(180,160,140,0.6);
}
.gravity-divider {
height: 1px;
margin-top: 4px;
background: linear-gradient(90deg, rgba(180,160,140,0.2), transparent);
}
.gravity-metric {
text-align: center;
padding: 12px 0;
}
.gravity-value {
font-size: 30px;
font-weight: 900;
letter-spacing: -0.02em;
color: rgba(255,255,255,0.9);
}
.gravity-unit {
font-size: 10px;
margin-top: 4px;
letter-spacing: 0.1em;
color: rgba(180,160,140,0.5);
}
.gravity-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.gravity-row-label {
font-size: 10px;
color: rgba(255,255,255,0.35);
}
.gravity-row-value {
font-size: 14px;
font-weight: 700;
color: rgba(180,160,140,0.8);
}
.gravity-weight {}
.gravity-weight-h {
display: flex;
justify-content: space-between;
font-size: 8px;
color: rgba(255,255,255,0.25);
margin-bottom: 4px;
}
.gravity-weight-track {
height: 6px;
border-radius: 8px;
background: rgba(255,255,255,0.06);
overflow: hidden;
}
.gravity-weight-fill {
height: 100%;
border-radius: 8px;
background: linear-gradient(90deg, rgba(180,160,140,0.2), rgba(180,160,140,0.6));
transition: width 1.5s ease-out;
}
.gravity-status {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
padding-top: 4px;
}
.gravity-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: rgba(180,160,140,0.3);
}
.gravity-status span {
font-size: 8px;
letter-spacing: 0.1em;
color: rgba(255,255,255,0.3);
}
@media (prefers-reduced-motion: reduce) {
.gravity-frame { transition: none; }
.gravity-frame:hover { transform: none; }
.gravity-weight-fill { transition: none; }
}Tailwind CSS
<div class="group relative w-[210px]">
<div class="absolute -bottom-4 left-[5%] right-[5%] h-6 rounded-full z-[-1] bg-black/30 blur-lg"></div>
<div class="relative rounded-xl overflow-hidden min-h-[290px] border border-white/10 shadow-[0_20px_50px_rgba(0,0,0,0.5)] cursor-grab active:cursor-grabbing active:scale-[0.98] bg-gradient-to-br from-[#2a2722] via-[#1a1814] to-[#0f0d0a]">
<div class="absolute inset-0 opacity-[0.03] pointer-events-none" style="background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1h1v1H1V1zm2 2h1v1H3V3z' fill='%23ffffff' fill-opacity='0.5'/%3E%3C/svg%3E")"></div>
<div class="relative z-10 p-5 space-y-4">
<div class="space-y-1">
<p class="text-[11px] font-semibold tracking-wider text-amber-800/60">Heavy Metal Dashboard</p>
<div class="h-px w-full bg-gradient-to-r from-amber-800/20 to-transparent"></div>
</div>
<div class="text-center py-3">
<p class="text-3xl font-black tracking-tight text-white/90">847 kg</p>
<p class="text-[10px] mt-1 tracking-wider text-amber-800/50">Total Load</p>
</div>
<div class="h-px w-full bg-gradient-to-r from-transparent via-amber-800/15 to-transparent"></div>
<div class="flex justify-between items-center">
<span class="text-[10px] text-white/35">Max Capacity</span>
<span class="text-sm font-bold text-amber-800/80">1,200 kg</span>
</div>
<div class="space-y-1">
<div class="flex justify-between text-[8px] text-white/25"><span>WEIGHT</span><span>75 kg</span></div>
<div class="h-1.5 rounded-full bg-white/5 overflow-hidden"><div class="h-full rounded-full bg-gradient-to-r from-amber-800/20 to-amber-800/60" style="width: 75%"></div></div>
</div>
<div class="flex items-center justify-center gap-2 pt-1">
<div class="w-1.5 h-1.5 rounded-full bg-amber-800/30"></div>
<span class="text-[8px] tracking-wider text-white/30">GROUNDED</span>
</div>
</div>
</div>
</div>React
import React, { useRef, useState, useCallback } from 'react';
import { motion, useMotionValue, useSpring } from 'framer-motion';
export function GravityCard() {
const ref = useRef<HTMLDivElement>(null);
const [isHovered, setIsHovered] = useState(false);
const [isDragging, setIsDragging] = useState(false);
const [clickBounce, setClickBounce] = useState(false);
const weight = 75;
const x = useMotionValue(0);
const y = useMotionValue(0);
const rotateX = useSpring(y, { damping: 25, stiffness: 250 });
const rotateY = useSpring(x, { damping: 25, stiffness: 250 });
const handleMouseMove = (e: React.MouseEvent) => {
if (!ref.current || isDragging) return;
const rect = ref.current.getBoundingClientRect();
const cx = rect.left + rect.width / 2;
const cy = rect.top + rect.height / 2;
x.set(-((e.clientX - cx) / (rect.width / 2)) * 10);
y.set(((e.clientY - cy) / (rect.height / 2)) * 10);
};
const handleClick = useCallback(() => {
setClickBounce(true);
setTimeout(() => setClickBounce(false), 300);
}, []);
const dustParticles = Array.from({ length: 6 }, (_, i) => ({ id: i, x: 20 + Math.random() * 60, y: 50 + Math.random() * 40, size: 1.5 + Math.random() * 2 }));
return (
<div onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => { setIsHovered(false); x.set(0); y.set(0); setIsDragging(false); }}>
<motion.div ref={ref} onMouseMove={handleMouseMove} onMouseDown={() => setIsDragging(true)} onMouseUp={() => setIsDragging(false)} onClick={handleClick}
style={{ rotateX, rotateY, transformStyle: 'preserve-3d' }} className="relative cursor-grab active:cursor-grabbing"
drag dragConstraints={{ left: 0, right: 0, top: 0, bottom: 0 }} dragElastic={0.4} whileDrag={{ scale: 0.98 }}>
<motion.div className="absolute -bottom-4 left-[5%] right-[5%] h-6 rounded-full z-[-1]" style={{ background: 'radial-gradient(ellipse, rgba(0,0,0,0.3), transparent)', filter: 'blur(8px)' }}
animate={{ scaleX: isDragging ? 0.95 : 1, opacity: isDragging ? 0.6 : 0.8 }} />
<motion.div className="relative overflow-hidden rounded-xl" style={{ width: 210, minHeight: 290, background: 'linear-gradient(160deg, #2a2722, #1a1814, #0f0d0a)', border: '1.5px solid rgba(180,160,140,0.15)' }}
animate={{ y: clickBounce ? [0, 4, -2, 0] : isDragging ? 2 : 0, scaleX: clickBounce ? [1, 0.98, 1.01, 1] : 1, scaleY: clickBounce ? [1, 1.02, 0.99, 1] : 1,
boxShadow: isDragging ? '0 30px 60px rgba(0,0,0,0.6)' : clickBounce ? '0 8px 20px rgba(0,0,0,0.3)' : '0 20px 50px rgba(0,0,0,0.5)' }}
transition={{ type: 'spring', stiffness: 800, damping: 15, mass: weight / 50 }}>
{dustParticles.map((dp) => (
<motion.div key={dp.id} className="absolute rounded-full pointer-events-none" style={{ left: `${dp.x}%`, top: `${dp.y}%`, width: dp.size, height: dp.size, background: 'rgba(255,255,255,0.15)' }}
animate={isHovered ? { opacity: [0, 0.6, 0], y: [0, -20 - dp.id * 3], x: [0, (dp.id % 2 === 0 ? 1 : -1) * (5 + dp.id * 2)] } : { opacity: 0 }}
transition={{ duration: 1.2 + dp.id * 0.2, repeat: isHovered ? Infinity : 0, delay: dp.id * 0.15, ease: 'easeOut' }} />
))}
<div className="absolute inset-0 opacity-[0.03] pointer-events-none" style={{ backgroundImage: 'url("data:image/svg+xml,%3Csvg width=\'4\' height=\'4\' viewBox=\'0 0 4 4\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M1 1h1v1H1V1zm2 2h1v1H3V3z\' fill=\'%23ffffff\' fill-opacity=\'0.5\'/%3E%3C/svg%3E")' }} />
<div className="relative z-10 p-5 space-y-4">
<div className="space-y-1"><p className="text-[11px] font-semibold tracking-wider" style={{ color: 'rgba(180,160,140,0.6)' }}>Heavy Metal Dashboard</p><div className="h-px w-full" style={{ background: 'linear-gradient(90deg, rgba(180,160,140,0.2), transparent)' }} /></div>
<motion.div className="text-center py-3" animate={isHovered ? { y: [0, -2, 0] } : {}} transition={{ duration: 2.5, repeat: isHovered ? Infinity : 0, ease: 'easeInOut' }}>
<motion.p className="text-3xl font-black tracking-tight" style={{ color: 'rgba(255,255,255,0.9)' }} animate={isHovered ? { scale: [1, 1.02, 1] } : {}} transition={{ duration: 2, repeat: isHovered ? Infinity : 0 }}>847 kg</motion.p>
<p className="text-[10px] mt-1 tracking-wider" style={{ color: 'rgba(180,160,140,0.5)' }}>Total Load</p>
</motion.div>
<div className="h-px w-full" style={{ background: 'linear-gradient(90deg, transparent, rgba(180,160,140,0.15), transparent)' }} />
<div className="flex justify-between items-center">
<span className="text-[10px]" style={{ color: 'rgba(255,255,255,0.35)' }}>Max Capacity</span>
<motion.span className="text-sm font-bold" style={{ color: 'rgba(180,160,140,0.8)' }} animate={isHovered ? { opacity: [0.6, 1, 0.6] } : {}} transition={{ duration: 2, repeat: isHovered ? Infinity : 0 }}>1,200 kg</motion.span>
</div>
<div className="space-y-1">
<div className="flex justify-between text-[8px]" style={{ color: 'rgba(255,255,255,0.25)' }}><span>WEIGHT</span><motion.span animate={isHovered ? { opacity: [0.4, 0.8, 0.4] } : {}} transition={{ duration: 1.5, repeat: isHovered ? Infinity : 0 }}>75 kg</motion.span></div>
<div className="h-1.5 rounded-full overflow-hidden" style={{ background: 'rgba(255,255,255,0.06)' }}>
<motion.div className="h-full rounded-full" style={{ background: 'linear-gradient(90deg, rgba(180,160,140,0.2), rgba(180,160,140,0.6))' }} initial={{ width: '0%' }} animate={{ width: '75%' }} transition={{ duration: 1.5, ease: 'easeOut' }} />
</div>
</div>
<motion.div className="flex items-center justify-center gap-2 pt-1" animate={isHovered ? { y: [0, -1, 0] } : {}} transition={{ duration: 2, repeat: isHovered ? Infinity : 0, delay: 0.3 }}>
<motion.span className="w-1.5 h-1.5 rounded-full" style={{ background: isHovered ? '#e8d5c0' : 'rgba(180,160,140,0.3)', boxShadow: isHovered ? '0 0 6px rgba(180,160,140,0.4)' : 'none' }} />
<span className="text-[8px] tracking-wider" style={{ color: 'rgba(255,255,255,0.3)' }}>{isHovered ? 'LIFTED' : 'GROUNDED'}</span>
</motion.div>
</div>
</motion.div>
</motion.div>
</div>
);
}Where Gravity Card fits
- Dashboards
- Product Cards
- Developer Tools
- Data Apps
- Gaming
- Interactive UI
Interaction states & animations
- Spring bounce
- Momentum drag
- Compression
- Dust particles
- Contact shadow
Topics
- #gravity
- #physics
- #weight
- #heavy
- #drag
- #bounce
- #momentum
- #spring
- #mass
- #realistic
Accessibility notes
Drag interaction should also work via keyboard. Compress animation should respect prefers-reduced-motion. Provide static fallback for motion-sensitive users.
Browser support
- Chrome 76+
- Firefox 90+
- Safari 13+
- Edge 79+