Skip to Content

Eclipse Scene

Solar eclipse background: a dark moon disc with a thin warm rim and a soft blurred corona on a near-black ground. Static, with an adjustable disc size, for astronomy and space themed heroes.

Installation

pnpm dlx shadcn@latest add @01orbital/eclipse-scene

Usage

"use client"

import { useEffect, useRef, useState } from "react"

import { EclipseScene } from "@/components/scene/eclipse-scene"

export default function EclipseSceneDemo() {
  const frameRef = useRef<HTMLDivElement>(null)
  const [size, setSize] = useState(150)

  useEffect(() => {
    const frame = frameRef.current
    if (!frame) return
    const observer = new ResizeObserver(([entry]) => {
      const { width, height } = entry.contentRect
      // The corona is 1.19× the disc, centered at 46% height. Reserve
      // 42px for its 14px blur on each side, plus 14px of breathing room.
      setSize(
        Math.max(
          0,
          Math.min(520, (width - 112) / 1.19, (height * 0.92 - 112) / 1.19)
        )
      )
    })
    observer.observe(frame)
    return () => observer.disconnect()
  }, [])

  return (
    <div ref={frameRef} className="relative isolate min-h-full w-full flex-1">
      <EclipseScene size={size} />
    </div>
  )
}

This example installs with everything it uses:

pnpm dlx shadcn@latest add @01orbital/eclipse-scene-demo

Examples

Teal Grandeclipse-scene-teal-grand

Eclipse Scene Teal Grand: an example of eclipse-scene.

pnpm dlx shadcn@latest add @01orbital/eclipse-scene-teal-grand

Wineeclipse-scene-wine

Eclipse Scene Wine: an example of eclipse-scene.

pnpm dlx shadcn@latest add @01orbital/eclipse-scene-wine

API reference

A total eclipse on its own near-black ground: dark disc, warm rim, soft corona.

Prop

Type

It also accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs it for you.

Used in blocks

One block is built with Eclipse Scene.

Last updated on