Backgrounds

Light Rays

Volumetric god-rays from a configurable origin, optionally mouse-following.

Adapted from React Bits

Install

bun add ogl

Then copy 2 files into your project:

  • components/registry/light-rays/light-rays.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
raysColorstring (hex)"#a855f7"Ray color.
raysSpeednumber1Animation speed.
lightSpreadnumber1Angular spread of the rays.
rayLengthnumber2Length of the rays.
pulsatingbooleanfalsePulse the ray intensity.
fadeDistancenumber1Distance over which rays fade.
saturationnumber1Color saturation.
followMousebooleantrueAim the rays toward the pointer. While on, the overlay claims touch input (a finger drag steers the rays instead of scrolling) and so intercepts clicks beneath it; off restores click-through.
mouseInfluencenumber0.1How much the cursor steers the rays.
noiseAmountnumber0.1Noise texture over the rays.
distortionnumber0.2Wavy distortion of the rays.

What It Demonstrates

Loop
An animation that repeats, a set number of times or infinitely.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
Hover effect
Visual change when the cursor moves over an element.

Related Components

Appears In