Sun Rays
A WebGL2 shader of soft sunbeams fanning out from just past the top edge, turning and shimmering slowly, with film grain.
Props
Position
Color
#d2b979
Rays14
Spread1.40
Reach0.90
Glow1.00
Grain1.0
Speed1.00
Strength1.00
Installation
pnpm dlx shadcn@latest add @breeze/sun-raysUsage
import { SunRays } from "@/components/breeze/sun-rays"It sits behind a hero, with the sun just off the top edge. The canvas is transparent, so your background shows through.
<section className="relative isolate overflow-hidden">
<SunRays className="absolute inset-0 -z-10 h-full w-full" />
{/* content */}
</section>Props
| Prop | Type | Default | Description |
|---|---|---|---|
color | string | "#d2b979" | Light colour, any CSS colour or var() |
position | "top" | "top-left" | "top-right" | "top" | Where the sun sits, just past the edge |
rays | number | 14 | How many beams. Higher is finer |
spread | number | 1.4 | How wide the beams fan out |
reach | number | 0.9 | How far the beams reach into the box |
glow | number | 1 | Brightness of the sun and its beams |
grain | number | 1 | Film grain amount. 0 for a clean finish |
speed | number | 1 | Animation speed multiplier. 0 freezes the rays |
strength | number | 1 | Opacity multiplier |
fps | number | 60 | Frame rate cap |
Every prop updates live without restarting the animation. It only ever uses color itself; the beams change how much of it shows. The beams turn and shimmer slowly, and light flows outward along them. On dark pages it glows a little softer, so it never floods the page. The animation pauses off-screen and shows a still frame with reduced motion.
Examples
From the corner
<SunRays
position="top-left"
color="#38bdf8"
rays={20}
className="absolute inset-0 h-full w-full"
/>