Sky
A WebGL2 shader of a deep blue sky with soft, smoky clouds. Day in light mode, a starry night in dark mode.
Installation
pnpm dlx shadcn@latest add @breeze/skyUsage
import { Sky } from "@/components/breeze/sky"It fills a hero as its background. The sky is opaque, deep at the top and paler toward the bottom, with soft, smoky clouds drifting across it. White text sits well on it in both modes. The canvas fills its box: put it in a positioned parent that has a size, as below, or give it a height of its own. In a box with no height it's 0 tall.
The sky fades in once it has drawn, and stays empty where WebGL2 isn't available, so give the section a matching background as a fallback. Otherwise white text sits on your page colour.
<section className="relative isolate overflow-hidden bg-[#1a46c8] dark:bg-[#0c1a4a]">
<Sky className="absolute inset-0 -z-10 h-full w-full" />
{/* content */}
</section>Props
| Prop | Type | Default | Description |
|---|---|---|---|
mode | "auto" | "day" | "night" | "auto" | "auto" follows the theme: day in light mode, night in dark mode |
color | string | "#1a46c8" | Daytime sky colour, any CSS colour or var() |
nightColor | string | "#0c1a4a" | Night sky colour, any CSS colour or var() |
cover | number | 0.6 | How much of the sky is cloud, 0 (clear) to 1 (overcast) |
scale | number | 1 | Size of the clouds. Higher is smaller |
speed | number | 1 | Drift speed multiplier. 0 freezes the sky |
stars | boolean | true | Stars at night |
grain | number | 1 | Film grain amount. 0 for a clean finish |
fps | number | 30 | Frame rate cap |
Every prop updates live without restarting the animation. The clouds sit on a plane overhead, so they shrink and thicken toward the horizon. In "auto" mode the sky eases from day to night over about a second when the theme changes. At night the clouds turn a moonlit grey-blue and a few stars twinkle behind them. It pauses off-screen and shows a still frame with reduced motion.
Any other canvas prop, like id, style or data-*, is passed to the canvas. It's aria-hidden unless you override it.
Examples
Day and night
<div className="absolute inset-0 grid grid-cols-2">
<Sky mode="day" className="h-full w-full" />
<Sky mode="night" className="h-full w-full" />
</div>Clear evening
<Sky
mode="day"
color="#3b2fb8"
cover={0.3}
scale={0.8}
className="absolute inset-0 h-full w-full"
/>