Skip to content

Constellation Card

Content exists as stars connected in space. Features a night sky with background stars, constellation pattern with animated connecting lines, nebula glow, and a shooting star on hover. Each star pulses with cosmic energy.

Constellation Card

by FreeCsStyles Dev's

CardsConstellation / Space
🌐🎨⚛️💚🅰️🔥☁️
#constellation#stars#space#nebula#cosmic#astronomy#night-sky#galaxy#science#universe

Embed this component

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

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

Implementation code

Copy the HTML and CSS for Constellation 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="constellation-card">
  <div class="c-nebula"></div>
  <div class="c-bg-stars"></div>
  <div class="c-constellation">
    <svg class="c-lines" width="100%" height="100%" viewBox="0 0 210 290">
      <line x1="35%" y1="52%" x2="50%" y2="50%" stroke="#a78bfa" stroke-width="0.5" stroke-dasharray="4 3" opacity="0.3"/>
      <line x1="50%" y1="50%" x2="65%" y2="52%" stroke="#a78bfa" stroke-width="0.5" stroke-dasharray="4 3" opacity="0.3"/>
      <line x1="30%" y1="32%" x2="72%" y2="30%" stroke="#a78bfa" stroke-width="0.5" stroke-dasharray="4 3" opacity="0.3"/>
    </svg>
    <div class="c-star" style="left: 35%; top: 52%;"></div>
    <div class="c-star" style="left: 50%; top: 50%;"></div>
    <div class="c-star" style="left: 65%; top: 52%;"></div>
    <div class="c-star" style="left: 30%; top: 32%;"></div>
    <div class="c-star" style="left: 72%; top: 30%;"></div>
    <div class="c-star" style="left: 25%; top: 72%;"></div>
    <div class="c-star" style="left: 75%; top: 70%;"></div>
  </div>
  <div class="c-content">
    <div class="c-header">
      <div>
        <div class="c-name">Orion</div>
        <div class="c-type">Constellation</div>
      </div>
      <div><div class="c-count">2.5k</div><div class="c-count-label">STARS</div></div>
    </div>
    <div class="c-divider"></div>
    <div class="c-stats">
      <div class="c-stat"><div class="c-stat-val">1,344 ly</div><div class="c-stat-lbl">Distance</div></div>
      <div class="c-stat"><div class="c-stat-val">Mag 0.12</div><div class="c-stat-lbl">Brightness</div></div>
    </div>
  </div>
</div>
CSS
.constellation-card {
  position: relative;
  width: 210px;
  min-height: 290px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(160deg, #0a0a1a, #060612);
  border: 1.5px solid rgba(255,255,255,0.04);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  transition: all 0.4s ease;
}

.constellation-card:hover {
  box-shadow: 0 0 40px rgba(167,139,250,0.08), 0 15px 40px rgba(0,0,0,0.4);
}

.c-nebula {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, rgba(167,139,250,0.04), transparent);
}

.c-bg-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.c-constellation {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.c-star {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.4);
  box-shadow: 0 0 4px rgba(167,139,250,0.1);
}

.c-content {
  position: relative;
  z-index: 10;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.c-type {
  font-size: 9px;
  color: rgba(167,139,250,0.5);
}

.c-count {
  font-size: 18px;
  font-weight: 200;
  color: rgba(255,255,255,0.7);
}

.c-count-label {
  font-size: 7px;
  color: rgba(255,255,255,0.2);
}

.c-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.15), transparent);
}

.c-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.c-stat {
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(167,139,250,0.06);
  border: 1px solid rgba(167,139,250,0.08);
}

.c-stat-val {
  font-size: 11px;
  font-weight: 600;
  color: #a78bfa;
}

.c-stat-lbl {
  font-size: 7px;
  margin-top: 2px;
  color: rgba(255,255,255,0.2);
}

@media (prefers-reduced-motion: reduce) {
  .c-star { animation: none !important; }
  .constellation-card:hover { transform: none; }
}
Tailwind CSS
<div class="group relative w-[210px] min-h-[290px] rounded-2xl overflow-hidden border border-white-50/10 shadow-lg group-hover:shadow-[0_0_40px_rgba(167,139,250,0.08),0_15px_40px_rgba(0,0,0,0.4)] bg-gradient-to-br from-[#0a0a1a] to-[#060612]">
  <div class="absolute inset-0 pointer-events-none bg-gradient-to-b from-purple-500/10 to-transparent opacity-50"></div>
  <div class="absolute inset-0 pointer-events-none">
    <svg width="100%" height="100%" viewBox="0 0 210 290" class="z-[1]">
      <line x1="35%" y1="52%" x2="50%" y2="50%" stroke="#a78bfa" stroke-width="0.5" stroke-dasharray="4 3" opacity="0.3"/>
      <line x1="50%" y1="50%" x2="65%" y2="52%" stroke="#a78bfa" stroke-width="0.5" stroke-dasharray="4 3" opacity="0.3"/>
    </svg>
  </div>
  <div class="relative z-10 p-5 space-y-3">
    <div class="flex items-center justify-between">
      <div><p class="text-sm font-bold text-white/90">Orion</p><p class="text-[9px] text-purple-500/50">Constellation</p></div>
      <div class="text-right"><p class="text-lg font-extralight text-white/70">2.5k</p><p class="text-[7px] text-white/20">STARS</p></div>
    </div>
    <div class="h-px bg-gradient-to-r from-transparent via-purple-500/15 to-transparent"></div>
    <div class="grid grid-cols-2 gap-2">
      <div class="text-center py-2 rounded-lg bg-purple-500/10 border border-purple-500/20"><p class="text-[11px] font-semibold text-purple-400">1,344 ly</p><p class="text-[7px] mt-0.5 text-white/20">Distance</p></div>
      <div class="text-center py-2 rounded-lg bg-purple-500/10 border border-purple-500/20"><p class="text-[11px] font-semibold text-purple-400">Mag 0.12</p><p class="text-[7px] mt-0.5 text-white/20">Brightness</p></div>
    </div>
  </div>
</div>
React
import React, { useState } from 'react';
import { motion } from 'framer-motion';

export function ConstellationCard() {
  const [isHovered, setIsHovered] = useState(false);

  const bgStars = Array.from({ length: 30 }, (_, i) => ({ id: i, x: Math.random() * 100, y: Math.random() * 100, size: 0.5 + Math.random() * 1.5, delay: Math.random() * 3 }));
  const cStars = [{ id: 's1', x: 35, y: 52 }, { id: 's2', x: 50, y: 50 }, { id: 's3', x: 65, y: 52 }, { id: 's4', x: 30, y: 32 }, { id: 's5', x: 72, y: 30 }, { id: 's6', x: 25, y: 72 }, { id: 's7', x: 75, y: 70 }];
  const lines = [[0,1],[1,2],[3,4],[0,3],[2,4],[0,5],[2,6]];

  return (
    <div onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
      <motion.div className="relative overflow-hidden rounded-2xl" style={{ width: 210, minHeight: 290, background: 'linear-gradient(160deg, #0a0a1a, #060612)', border: '1.5px solid rgba(255,255,255,0.04)' }}
        animate={{ boxShadow: isHovered ? '0 0 40px rgba(167,139,250,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 }}>
        <motion.div className="absolute inset-0 pointer-events-none" animate={{ background: isHovered ? 'radial-gradient(ellipse at 50% 60%, rgba(167,139,250,0.08), transparent 70%)' : 'radial-gradient(ellipse at 50% 60%, rgba(167,139,250,0.04), transparent)' }} transition={{ duration: 1.5 }} />
        {bgStars.map((star) => (
          <motion.div key={star.id} className="absolute rounded-full pointer-events-none" style={{ left: `${star.x}%`, top: `${star.y}%`, width: star.size, height: star.size, background: 'rgba(255,255,255,0.3)' }}
            animate={{ opacity: [0.2, 0.8, 0.2] }} transition={{ duration: 1.5 + star.delay, repeat: Infinity, ease: 'easeInOut', delay: star.delay }} />
        ))}
        <svg className="absolute inset-0 w-full h-full pointer-events-none z-[1]">
          {lines.map(([fromIdx, toIdx], i) => {
            const from = cStars[fromIdx];
            const to = cStars[toIdx];
            return <motion.line key={i} x1={`${from.x}%`} y1={`${from.y}%`} x2={`${to.x}%`} y2={`${to.y}%`} stroke="#a78bfa" strokeWidth="0.5" strokeDasharray="4 3"
              initial={{ pathLength: 0, opacity: 0 }} animate={isHovered ? { pathLength: 1, opacity: 0.4 } : { pathLength: 0, opacity: 0 }}
              transition={{ duration: 1.5, delay: i * 0.1 }} />;
          })}
        </svg>
        {cStars.map((star, i) => (
          <motion.div key={star.id} className="absolute z-[2] rounded-full pointer-events-none" style={{ left: `${star.x}%`, top: `${star.y}%`, width: 8, height: 8, transform: 'translate(-50%, -50%)', background: 'rgba(255,255,255,0.6)' }}
            animate={isHovered ? { scale: [1, 1.2, 1], boxShadow: ['0 0 4px rgba(167,139,250,0.1)', '0 0 10px rgba(167,139,250,0.3)', '0 0 4px rgba(167,139,250,0.1)'] } : { scale: 1, boxShadow: '0 0 4px rgba(255,255,255,0.1)' }}
            transition={{ duration: 2, repeat: isHovered ? Infinity : 0, delay: 0.1 * i }} />
        ))}
        {isHovered && (
          <motion.div className="absolute pointer-events-none z-[3]" initial={{ left: '-10%', top: '-10%', opacity: 1 }} animate={{ left: '110%', top: '110%', opacity: [1, 0.8, 0] }} transition={{ duration: 1.2, repeat: Infinity, delay: 2, ease: 'easeIn' }}>
            <div className="w-px h-8" style={{ background: 'linear-gradient(180deg, #a78bfa, transparent)', transform: 'rotate(45deg)', boxShadow: '0 0 4px #a78bfa' }} />
          </motion.div>
        )}
        <div className="relative z-10 p-5 space-y-3">
          <div className="flex items-center justify-between">
            <div><p className="text-sm font-bold text-white/90">Orion</p><p className="text-[9px]" style={{ color: 'rgba(167,139,250,0.5)' }}>Constellation</p></div>
            <motion.div className="text-right" animate={isHovered ? { y: [0, -2, 0] } : {}} transition={{ duration: 2, repeat: isHovered ? Infinity : 0 }}>
              <p className="text-lg font-extralight text-white/70">2.5k</p>
              <p className="text-[7px] text-white/20">STARS</p>
            </motion.div>
          </div>
          <div className="h-px" style={{ background: 'linear-gradient(90deg, transparent, rgba(167,139,250,0.15), transparent)' }} />
          <div className="grid grid-cols-2 gap-2">
            {[{ label: 'Distance', value: '1,344 ly' }, { label: 'Brightness', value: 'Mag 0.12' }].map((stat) => (
              <div key={stat.label} className="text-center py-2 rounded-lg" style={{ background: 'rgba(167,139,250,0.06)', border: '1px solid rgba(167,139,250,0.08)' }}>
                <p className="text-[11px] font-semibold" style={{ color: '#a78bfa' }}>{stat.value}</p>
                <p className="text-[7px] mt-0.5 text-white/20">{stat.label}</p>
              </div>
            ))}
          </div>
        </div>
      </motion.div>
    </div>
  );
}

Where Constellation Card fits

  • Education
  • Science
  • Space
  • AI
  • Astronomy
  • Fantasy

Interaction states & animations

  • Star pulse
  • Constellation draw
  • Shooting star
  • Nebula glow
  • Line animation

Topics

  • #constellation
  • #stars
  • #space
  • #nebula
  • #cosmic
  • #astronomy
  • #night-sky
  • #galaxy
  • #science
  • #universe

Accessibility notes

Animated constellation lines may be distracting. Provide prefers-reduced-motion that prevents line animations and star pulsing. Ensure text contrast against dark backgrounds.

Browser support

  • Chrome 76+
  • Firefox 90+
  • Safari 13+
  • Edge 79+