Skip to content

Universe Creation Card

Creates an entire universe from nothing. Starts as empty black space and evolves through Big Bang, star formation, galaxy creation, and full cosmic expansion.

Universe Creation Card

by FreeCsStyles Dev's

CardsUniverse Creation
🌐🎨⚛️

Embed this component

Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/universe-creation-card.

<iframe src="/embed/universe-creation-card" sandbox="allow-scripts" loading="lazy" title="Universe Creation Card" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Universe Creation 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="universe-card" onclick="nextPhase(this)">
  <div class="universe-bang"></div>
  <div class="universe-stars"></div>
  <div class="universe-galaxies"></div>
  <div class="universe-nebulas"></div>
  <div class="universe-aurora"></div>
  <div class="universe-meteors"></div>
  <div class="universe-content">
    <div class="universe-header">
      <div><div class="universe-title">Cosmos Alpha</div><div class="universe-sub">Universe Simulation</div></div>
      <div class="universe-age"><div class="universe-age-val">13.8</div><div class="universe-age-lbl">AGE</div></div>
    </div>
    <div class="universe-divider"></div>
    <div class="universe-grid">
      <div class="universe-stat"><div class="universe-stat-val">2T</div><div class="universe-stat-lbl">Galaxies</div></div>
      <div class="universe-stat"><div class="universe-stat-val">73</div><div class="universe-stat-lbl">Expansion</div></div>
    </div>
    <div class="universe-hint" id="universe-hint">[hover to begin]</div>
  </div>
</div>
<script>
let phase = 0;
document.querySelector('.universe-card').addEventListener('mouseenter', function() {
  if (phase === 0) { phase = 1; updatePhase(this); }
});
function nextPhase(el) {
  if (phase < 4) phase++;
  else phase = 0;
  updatePhase(el);
}
function updatePhase(el) {
  el.className = 'universe-card';
  if (phase >= 1) el.classList.add('phase-bang');
  if (phase >= 2) el.classList.add('phase-stars');
  if (phase >= 3) el.classList.add('phase-galaxies');
  if (phase >= 4) el.classList.add('phase-full');
  document.getElementById('universe-hint').textContent = 
    phase >= 4 ? '[✦ recreate universe]' : '[▼ click to evolve]';
}
</script>
CSS
.universe-card {
  position: relative;
  width: 220px;
  min-height: 300px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(160deg, #050510, #020208);
  border: 1.5px solid rgba(255,255,255,0.03);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: all 0.4s ease;
}

.universe-card:hover {
  box-shadow: 0 0 40px rgba(167,139,250,0.06), 0 15px 40px rgba(0,0,0,0.5);
}

.universe-bang { display: none; position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.phase-bang .universe-bang {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bangAnim 1.5s ease-out;
}

@keyframes bangAnim {
  0% { opacity: 0; scale: 0; }
  50% { opacity: 1; scale: 3; }
  100% { opacity: 0.3; scale: 1; }
}

.universe-bang::after {
  content: '';
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, #a78bfa, #7c3aed, transparent);
  filter: blur(8px);
  box-shadow: 0 0 40px #a78bfa, 0 0 80px #7c3aed;
}

.universe-stars { display: none; position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.phase-stars .universe-stars { display: block; }

.universe-stars::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(1px 1px at 10% 20%, rgba(167,139,250,0.8), transparent),
    radial-gradient(1.5px 1.5px at 30% 50%, rgba(167,139,250,0.6), transparent),
    radial-gradient(1px 1px at 50% 10%, rgba(167,139,250,0.8), transparent);
  animation: starTwinkle 2s ease-in-out infinite alternate;
}

@keyframes starTwinkle {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

.universe-galaxies { display: none; position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.phase-galaxies .universe-galaxies { display: block; }

.universe-nebulas { display: none; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.phase-full .universe-nebulas {
  display: block;
  background: radial-gradient(ellipse at 20% 25%, rgba(167,139,250,0.06), transparent 50%),
    radial-gradient(ellipse at 50% 40%, rgba(167,139,250,0.04), transparent 50%);
}

.universe-aurora { display: none; position: absolute; top: 0; left: 0; right: 0; height: 80px; z-index: 2; pointer-events: none; }
.phase-full .universe-aurora {
  display: block;
  background: linear-gradient(180deg, rgba(167,139,250,0.08), transparent);
  animation: auroraFlow 4s ease-in-out infinite;
}

@keyframes auroraFlow {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 0.5; transform: translateY(3px); }
}

.universe-meteors { display: none; position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.universe-card:hover .universe-meteors { display: block; }

.universe-content {
  position: absolute;
  inset-x: 0;
  bottom: 0;
  z-index: 10;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent);
}

.universe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.universe-title {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
}

.universe-sub {
  font-size: 9px;
  color: rgba(167,139,250,0.44);
}

.universe-age { text-align: right; }
.universe-age-val {
  font-size: 18px;
  font-weight: 200;
  color: rgba(255,255,255,0.7);
}
.universe-age-lbl {
  font-size: 7px;
  color: rgba(255,255,255,0.2);
}
.universe-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.08), transparent);
}
.universe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.universe-stat {
  text-align: center;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(167,139,250,0.02);
  border: 1px solid rgba(167,139,250,0.06);
}
.universe-stat-val {
  font-size: 10px;
  font-weight: 600;
  color: #a78bfa;
}
.universe-stat-lbl {
  font-size: 7px;
  margin-top: 2px;
  color: rgba(255,255,255,0.2);
}
.universe-hint {
  text-align: center;
  font-size: 7px;
  font-family: monospace;
  color: rgba(167,139,250,0.2);
}

@media (prefers-reduced-motion: reduce) {
  .universe-card { transition: none; }
  .universe-bang { animation: none; }
  .universe-stars::before { animation: none; }
  .universe-aurora { animation: none; }
}
Tailwind CSS
<div class="group relative w-[220px] min-h-[300px] rounded-2xl overflow-hidden border border-white/10 shadow-lg group-hover:shadow-[0_0_40px_rgba(167,139,250,0.06),0_15px_40px_rgba(0,0,0,0.5)] bg-gradient-to-br from-[#050510] to-[#020208] cursor-pointer">
  <div class="absolute inset-x-0 bottom-0 z-10 p-5 space-y-2 bg-gradient-to-t from-black/60 to-transparent">
    <div class="flex items-center justify-between">
      <div><p class="text-sm font-bold text-white/90">Cosmos Alpha</p><p class="text-[9px] text-purple-400/50">Universe Simulation</p></div>
      <div class="text-right"><p class="text-lg font-extralight text-white/70">13.8</p><p class="text-[7px] text-white/20">AGE</p></div>
    </div>
    <div class="h-px bg-gradient-to-r from-transparent via-purple-400/20 to-transparent"></div>
    <div class="grid grid-cols-2 gap-2">
      <div class="text-center py-1.5 rounded-lg bg-purple-500/10 border border-purple-500/20"><p class="text-[10px] font-semibold text-purple-400">2T</p><p class="text-[7px] mt-0.5 text-white/20">Galaxies</p></div>
      <div class="text-center py-1.5 rounded-lg bg-purple-500/10 border border-purple-500/20"><p class="text-[10px] font-semibold text-purple-400">73</p><p class="text-[7px] mt-0.5 text-white/20">Expansion</p></div>
    </div>
    <div class="text-center"><span class="text-[7px] font-mono text-purple-400/30">[hover to begin]</span></div>
  </div>
</div>
React
import React, { useState, useRef } from 'react';
import { motion, useMotionValue, useSpring } from 'framer-motion';

export function UniverseCreationCard() {
  const [isHovered, setIsHovered] = useState(false);
  const [phase, setPhase] = useState(0);
  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 handleClick = () => setPhase((prev) => (prev >= 4 ? 0 : prev + 1));
  const galaxyPositions = [
    { x: '20%', y: '25%', size: 30, angle: 15, stars: 8 },
    { x: '65%', y: '30%', size: 25, angle: -20, stars: 6 },
    { x: '40%', y: '55%', size: 35, angle: 30, stars: 10 },
    { x: '75%', y: '60%', size: 20, angle: -10, stars: 5 },
    { x: '25%', y: '65%', size: 28, angle: 40, stars: 7 },
  ];
  return (
    <div onMouseEnter={() => { setIsHovered(true); if (phase === 0) setPhase(1); }} onMouseLeave={() => { setIsHovered(false); }}>
      <motion.div ref={ref} onMouseMove={handleMouseMove} onClick={handleClick} 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, #050510, #020208)', border: '1.5px solid rgba(255,255,255,0.03)' }}
          animate={{ boxShadow: isHovered ? '0 0 40px rgba(167,139,250,0.06), 0 15px 40px rgba(0,0,0,0.5)' : '0 10px 30px rgba(0,0,0,0.3)' }} transition={{ type: 'spring', stiffness: 280, damping: 20 }}>
          {phase >= 1 && (
            <motion.div className="absolute inset-0 flex items-center justify-center pointer-events-none z-[5]" initial={{ opacity: 0, scale: 0 }}
              animate={{ opacity: [0, 1, 0.3], scale: [0, 3, 1] }} transition={{ duration: 1.5, ease: 'easeOut' }}>
              <motion.div className="rounded-full" style={{ width: 60, height: 60, background: 'radial-gradient(circle, #a78bfa, #7c3aed, transparent)', filter: 'blur(8px)', boxShadow: '0 0 40px #a78bfa, 0 0 80px #7c3aed' }} />
            </motion.div>
          )}
          {phase >= 2 && (
            <div className="absolute inset-0 pointer-events-none z-[4]">
              {[...Array(15)].map((_, i) => (
                <motion.div key={i} className="absolute rounded-full" style={{ left: `${5 + Math.random() * 90}%`, top: `${5 + Math.random() * 90}%`, width: 1 + Math.random() * 2, height: 1 + Math.random() * 2, background: '#a78bfa' }}
                  initial={{ opacity: 0, scale: 0 }} animate={{ opacity: [0.2, 0.8, 0.2], scale: [0.5, 1, 0.5] }}
                  transition={{ duration: 1.5 + Math.random(), repeat: Infinity, delay: Math.random() }} />
              ))}
            </div>
          )}
          {phase >= 3 && galaxyPositions.map((gal, i) => (
            <motion.div key={i} className="absolute pointer-events-none z-[3]" style={{ left: gal.x, top: gal.y }}
              initial={{ opacity: 0, scale: 0 }} animate={{ opacity: isHovered ? 0.4 : 0.2, scale: 1, rotate: [gal.angle, gal.angle + 360] }}
              transition={{ opacity: { duration: 0.8, delay: i * 0.15 }, rotate: { duration: 20 + i * 5, repeat: Infinity, ease: 'linear' } }}>
              <div className="relative" style={{ width: gal.size, height: gal.size }}>
                <div className="absolute inset-0 rounded-full" style={{ background: `radial-gradient(ellipse at 30% 30%, rgba(167,139,250,0.12), transparent)` }} />
                {[...Array(gal.stars)].map((_, si) => (
                  <div key={si} className="absolute rounded-full" style={{ left: `${30 + Math.cos(si * Math.PI * 2 / gal.stars) * 40}%`, top: `${30 + Math.sin(si * Math.PI * 2 / gal.stars) * 40}%`, width: 1.5, height: 1.5, background: '#a78bfa', opacity: 0.5 }} />
                ))}
                <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1.5 h-1.5 rounded-full" style={{ background: '#a78bfa', boxShadow: '0 0 6px #a78bfa' }} />
              </div>
            </motion.div>
          ))}
          {phase >= 4 && (
            <div className="absolute inset-0 pointer-events-none z-[2]">
              {[...Array(3)].map((_, i) => (
                <motion.div key={i} className="absolute rounded-full" style={{ left: `${10 + i * 30}%`, top: `${15 + i * 12}%`, width: 60 + i * 20, height: 40 + i * 15, background: 'radial-gradient(ellipse, rgba(167,139,250,0.06), transparent)', filter: 'blur(10px)' }}
                  animate={{ scale: [1, 1.2, 1], opacity: [0.2, 0.4, 0.2] }} transition={{ duration: 3 + i, repeat: Infinity, ease: 'easeInOut' }} />
              ))}
            </div>
          )}
          {isHovered && [...Array(3)].map((_, i) => (
            <motion.div key={i} className="absolute pointer-events-none z-[6]" initial={{ left: '-10%', top: `${10 + i * 20}%`, opacity: 1 }}
              animate={{ left: '110%', top: `${30 + i * 15}%`, opacity: [1, 0.6, 0] }}
              transition={{ duration: 1.5 + i * 0.3, repeat: Infinity, delay: i * 1.5, ease: 'easeIn' }}>
              <div className="w-px h-6" style={{ background: 'linear-gradient(180deg, #a78bfa, transparent)', transform: 'rotate(30deg)' }} />
            </motion.div>
          ))}
          {phase >= 4 && (
            <motion.div className="absolute top-0 left-0 right-0 h-20 pointer-events-none z-[2]" style={{ background: 'linear-gradient(180deg, rgba(167,139,250,0.08), transparent)' }}
              animate={{ opacity: [0.2, 0.5, 0.2], y: [0, 3, 0] }} transition={{ duration: 4, repeat: Infinity, ease: 'easeInOut' }} />
          )}
          <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.6), transparent)' }}>
            <div className="flex items-center justify-between">
              <div><p className="text-sm font-bold text-white/90">Cosmos Alpha</p><p className="text-[9px]" style={{ color: 'rgba(167,139,250,0.44)' }}>Universe Simulation</p></div>
              <div className="text-right"><p className="text-lg font-extralight text-white/70">13.8</p><p className="text-[7px] text-white/20">AGE</p></div>
            </div>
            <div className="h-px" style={{ background: 'linear-gradient(90deg, transparent, rgba(167,139,250,0.08), transparent)' }} />
            <div className="grid grid-cols-2 gap-2">
              <div className="text-center py-1.5 rounded-lg" style={{ background: 'rgba(167,139,250,0.02)', border: '1px solid rgba(167,139,250,0.06)' }}>
                <p className="text-[10px] font-semibold" style={{ color: '#a78bfa' }}>2T</p><p className="text-[7px] mt-0.5 text-white/20">Galaxies</p>
              </div>
              <div className="text-center py-1.5 rounded-lg" style={{ background: 'rgba(167,139,250,0.02)', border: '1px solid rgba(167,139,250,0.06)' }}>
                <p className="text-[10px] font-semibold" style={{ color: '#a78bfa' }}>73</p><p className="text-[7px] mt-0.5 text-white/20">Expansion</p>
              </div>
            </div>
            <motion.div className="text-center pt-1" animate={isHovered ? { y: [0, -1, 0] } : {}} transition={{ duration: 1.5, repeat: isHovered ? Infinity : 0 }}>
              <span className="text-[7px] font-mono" style={{ color: 'rgba(167,139,250,0.2)' }}>{phase >= 4 ? '[✦ recreate universe]' : phase === 0 ? '[hover to begin]' : '[▼ click to evolve]'}</span>
            </motion.div>
          </div>
        </motion.div>
      </motion.div>
    </div>
  );
}

Interaction states & animations

  • Hover