Vilqor

Starry Sky Background

Heroes

About

A quiet night sky for dark sections: seeded stars, a few that twinkle, four sparkles and rare shooting stars. Fills its parent and stays still with reduced motion. Part of Midnight, the full template on 21st; also in the free Midnight Lite (MIT).

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Starry Sky Background to your project and fits it to your theme.

Code

How Starry Sky Background is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { useSyncExternalStore, type CSSProperties } from "react"

import { NightSky } from "@/components/ui/night-sky"

const fraunces =
  "@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,300..600,0..100;1,9..144,300..600,0..100&display=swap');"

const settings = {
  stars: 170,
  meteors: 3,
  sparkles: true,
  seed: 7,
  paper: "#f7f5f0",
  ink: "#141a2e",
  starColor: "#a5813f",
  accent: "#8a6a2e",
}

// Midnight by night, the template's own palette
const night: Partial<typeof settings> = {
  paper: "#0b1020",
  ink: "#ece9e1",
  starColor: "#ece9e1",
  accent: "#d9b77e",
}

// 21st marks its dark theme with .dark on <html>; the demo answers with Midnight by night
function useDark() {
  return useSyncExternalStore(
    (on) => {
      const watch = new MutationObserver(on)
      watch.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] })
      return () => watch.disconnect()
    },
    () => document.documentElement.classList.contains("dark"),
    () => false,
  )
}

export default function Demo(props: Partial<typeof settings>) {
  const dark = useDark()
  const s = { ...settings, ...props, ...(dark ? night : {}) }
  return (
    <div className="relative flex min-h-svh w-full items-center justify-center overflow-hidden px-6" style={{ background: s.paper }}>
      <style>{fraunces}</style>
      <NightSky
        stars={s.stars}
        seed={s.seed}
        sparkles={s.sparkles}
        meteors={s.meteors}
        starColor={s.starColor}
        accent={s.accent}
        style={(dark ? {} : { "--mn-glint": s.accent, "--mn-star-k": "1.8" }) as CSSProperties}
      />
      <h2
        className="relative text-center text-[clamp(44px,8vw,96px)] leading-[0.98] tracking-[-0.03em]"
        style={{ color: s.ink, fontFamily: "Fraunces, ui-serif, Georgia, serif", fontWeight: 340, fontVariationSettings: '"SOFT" 60, "opsz" 144' }}
      >
        Your work,
        <br />
        <em style={{ color: s.accent }}>done by morning.</em>
      </h2>
    </div>
  )
}

Dependencies

More by Vilqor

View all
  • 3D Glass Cube Hero

    3D Glass Cube Hero

    210
  • Footer with Big Wordmark

    Footer with Big Wordmark

    163
  • Guilloche Background Pattern

    Guilloche Background Pattern

    8
  • Card Carousel to Grid

    Card Carousel to Grid

  • AI Email Reply with Tones

    AI Email Reply with Tones

  • AI Memory Timeline

    AI Memory Timeline

  • Use Cases Tabs Section

    Use Cases Tabs Section

  • Pricing Section with Toggle

    Pricing Section with Toggle

More in Heroes

View all
  • Agency Hero Section

    Agency Hero Section

    1.1K
  • Real Estate 3D Hero

    Real Estate 3D Hero

    86
  • Responsive Hero Banner

    Responsive Hero Banner

    2.2K
  • SaaS Template

    SaaS Template

    2.8K
  • AI SaaS Workflow Hero

    AI SaaS Workflow Hero

    35
  • Hero

    Hero

    1.4K
  • App Integration Celestial Hero

    App Integration Celestial Hero

    17
  • Chroma Sense Hero

    Chroma Sense Hero

    22