Planetarium Card
Deep space background with slowly drifting starfields. Content orbits like planets around a central sun (the title). Hovering over a planet reveals its moon. Clicking a planet zooms in, transforming into a constellation view.
Planetarium Card
by FreeCsStyles Dev's
CardsPlanetarium
🌐HTML/CSS🎨Tailwind⚛️React
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/planetarium-card.
<iframe src="/embed/planetarium-card" sandbox="allow-scripts" loading="lazy" title="Planetarium Card" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Planetarium 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="planetarium-card">
<div class="starfield"></div>
<div class="nebula-glow"></div>
<div class="planetarium-sun">☀️</div>
<div class="planetarium-planets">
<span class="planet">🪐</span>
<span class="planet">🔴</span>
<span class="planet">🟠</span>
<span class="planet">🔵</span>
</div>
<div class="planetarium-content">
<div class="planetarium-header">
<div><div class="planetarium-title">Andromeda</div><div class="planetarium-stars">1000 stars</div></div>
<div class="planetarium-status">🌌 VIEW</div>
</div>
<div class="planetarium-divider"></div>
<div class="planetarium-stats">
<div class="planetarium-stat"><div class="planetarium-stat-val">1000</div><div class="planetarium-stat-lbl">Stars</div></div>
<div class="planetarium-stat"><div class="planetarium-stat-val">4</div><div class="planetarium-stat-lbl">Planets</div></div>
</div>
<div class="planetarium-hint">[▼ click planet to explore]</div>
</div>
</div>CSS
.planetarium-card {
position: relative;
width: 220px;
min-height: 300px;
border-radius: 16px;
overflow: hidden;
background: linear-gradient(160deg, #0a0510, #06030a);
border: 1.5px solid rgba(244,114,182,0.08);
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
cursor: pointer;
transition: all 0.4s ease;
}
.planetarium-card:hover {
box-shadow: 0 0 30px rgba(244,114,182,0.08), 0 15px 40px rgba(0,0,0,0.4);
}
.starfield {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 1;
}
.planetarium-sun {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 22%;
z-index: 5;
text-align: center;
}
.planetarium-content {
position: absolute;
inset-x: 0;
bottom: 0;
z-index: 10;
padding: 20px;
background: linear-gradient(0deg, rgba(0,0,0,0.5), transparent);
}
.planetarium-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.planetarium-title { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.9); }
.planetarium-stars { font-size: 9px; color: rgba(244,114,182,0.44); }
.planetarium-status { padding: 2px 8px; border-radius: 2px; font-size: 7px; font-weight: 700; letter-spacing: 0.1em; color: #f472b6; background: rgba(244,114,182,0.1); border: 1px solid rgba(244,114,182,0.12); }
.planetarium-divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(244,114,182,0.08), transparent); margin-bottom: 8px; }
.planetarium-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.planetarium-stat { text-align: center; padding: 6px; border-radius: 8px; background: rgba(244,114,182,0.02); border: 1px solid rgba(244,114,182,0.06); }
.planetarium-stat-val { font-size: 10px; font-weight: 600; color: #f472b6; }
.planetarium-stat-lbl { font-size: 7px; margin-top: 2px; color: rgba(255,255,255,0.2); }
.planetarium-hint { text-align: center; font-size: 7px; font-family: monospace; color: rgba(244,114,182,0.2); margin-top: 8px; }Tailwind CSS
<div class="group relative w-[220px] min-h-[300px] rounded-2xl overflow-hidden border border-pink-400/20 shadow-lg group-hover:shadow-[0_0_30px_rgba(244,114,182,0.08),0_15px_40px_rgba(0,0,0,0.4)] bg-gradient-to-br from-[#0a0510] to-[#06030a] cursor-pointer">
<div class="absolute inset-x-0 bottom-0 z-10 p-5 space-y-2 bg-gradient-to-t from-black/50 to-transparent">
<div class="flex items-center justify-between">
<div><p class="text-sm font-bold text-white/90">Andromeda</p><p class="text-[9px] text-pink-400/50">1000 stars</p></div>
<div class="px-2 py-0.5 rounded-sm text-[7px] font-bold tracking-widest text-pink-400 bg-pink-500/10 border border-pink-500/20">🌌 VIEW</div>
</div>
<div class="h-px bg-gradient-to-r from-transparent via-pink-400/20 to-transparent"></div>
<div class="grid grid-cols-2 gap-2">
<div class="text-center py-1.5 rounded-lg bg-pink-500/10 border border-pink-500/20"><p class="text-[10px] font-semibold text-pink-400">1000</p><p class="text-[7px] mt-0.5 text-white/20">Stars</p></div>
<div class="text-center py-1.5 rounded-lg bg-pink-500/10 border border-pink-500/20"><p class="text-[10px] font-semibold text-pink-500">4</p><p class="text-[7px] mt-0.5 text-white/20">Planets</p></div>
</div>
<div class="text-center"><span class="text-[7px] font-mono text-pink-400/30">[▼ click planet to explore]</span></div>
</div>
</div>React
import React, { useState, useRef } from 'react';
import { motion, useMotionValue, useSpring } from 'framer-motion';
export function PlanetariumCard() {
const [isHovered, setIsHovered] = useState(false);
const [activePlanet, setActivePlanet] = useState(null);
const [viewMode, setViewMode] = useState('galaxy');
const ref = useRef(null);
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();
const cx = rect.left + rect.width / 2;
const cy = rect.top + rect.height / 2;
x.set(-((e.clientX - cx) / (rect.width / 2)) * 6);
y.set(((e.clientY - cy) / (rect.height / 2)) * 6);
};
const planets = [{ id: 0, emoji: '🪐', moon: '🌑', label: 'Titan' }, { id: 1, emoji: '🔴', moon: '🌕', label: 'Phobos' }, { id: 2, emoji: '🟠', moon: '🌙', label: 'Europa' }, { id: 3, emoji: '🔵', moon: '⭐', label: 'Ganymede' }];
return (
<div onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => { setIsHovered(false); x.set(0); y.set(0); }}>
<motion.div ref={ref} onMouseMove={handleMouseMove} onClick={() => { if (viewMode === 'constellation') setViewMode('galaxy'); else if (activePlanet !== null) setViewMode('constellation'); }} style={{ rotateX, rotateY, transformStyle: 'preserve-3d', cursor: 'pointer' }}>
<motion.div className="relative overflow-hidden rounded-2xl" style={{ width: 220, minHeight: 300, background: 'linear-gradient(160deg, #0a0510, #06030a)', border: '1.5px solid rgba(244,114,182,0.08)' }}
animate={{ boxShadow: isHovered ? '0 0 30px rgba(244,114,182,0.08), 0 15px 40px rgba(0,0,0,0.4)' : '0 10px 30px rgba(0,0,0,0.3)' }} transition={{ type: 'spring', stiffness: 280, damping: 20 }}>
<div className="absolute inset-x-0 bottom-0 z-10 p-5 space-y-2" style={{ background: 'linear-gradient(0deg, rgba(0,0,0,0.5), transparent)' }}>
<div className="flex items-center justify-between">
<div><p className="text-sm font-bold text-white/90">Andromeda</p><p className="text-[9px]" style={{ color: 'rgba(244,114,182,0.44)' }}>1000 stars</p></div>
<motion.div className="px-2 py-0.5 rounded-sm text-[7px] font-bold tracking-widest" style={{ background: 'rgba(244,114,182,0.1)', border: '1px solid rgba(244,114,182,0.12)', color: '#f472b6' }}>{viewMode === 'constellation' ? '✨ CONST' : '🌌 VIEW'}</motion.div>
</div>
<div className="h-px" style={{ background: 'linear-gradient(90deg, transparent, rgba(244,114,182,0.08), transparent)' }} />
<div className="grid grid-cols-2 gap-2">
<div className="text-center py-1.5 rounded-lg" style={{ background: 'rgba(244,114,182,0.02)', border: '1px solid rgba(244,114,182,0.06)' }}><p className="text-[10px] font-semibold" style={{ color: '#f472b6' }}>1000</p><p className="text-[7px] mt-0.5 text-white/20">Stars</p></div>
<div className="text-center py-1.5 rounded-lg" style={{ background: 'rgba(244,114,182,0.02)', border: '1px solid rgba(244,114,182,0.06)' }}><p className="text-[10px] font-semibold" style={{ color: '#ec4899' }}>4</p><p className="text-[7px] mt-0.5 text-white/20">Planets</p></div>
</div>
<motion.div className="text-center" animate={isHovered ? { y: [0, -1, 0] } : {}} transition={{ duration: 1.5, repeat: isHovered ? Infinity : 0 }}>
<span className="text-[7px] font-mono" style={{ color: 'rgba(244,114,182,0.2)' }}>{viewMode === 'constellation' ? '[▼ back to galaxy]' : '[▼ click planet to explore]'}</span>
</motion.div>
</div>
</motion.div>
</motion.div>
</div>
);
}Interaction states & animations
- Hover