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>
)
}
















