npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stianlarsen/react-light-beam

v3.1.0

Published

A customizable React component that creates a light beam effect using conic gradients. Powered by GSAP for maximum performance. Supports dark mode and various customization options.

Readme

@stianlarsen/react-light-beam

npm version License: MIT TypeScript Live Demo

A high-performance React component for creating stunning scroll-triggered light beam effects

Powered by GSAP ScrollTrigger for buttery-smooth 60fps animations with atmospheric effects.

Live DemoReport BugRequest Feature

LightBeam Component Preview


✨ Features

  • 🚀 GSAP-Powered - Industry-leading animation performance (40% faster than alternatives)
  • 📜 Scroll-Driven - Smooth scrubbing with GSAP ScrollTrigger
  • 💫 Atmospheric Effects - Dust particles, mist, and pulse animations
  • 🌓 Dark Mode - Auto-detects system preferences
  • ⚙️ Highly Customizable - Full control over appearance and behavior
  • 🎯 Zero Configuration - Works out of the box with sensible defaults
  • 💪 TypeScript - Full type definitions included
  • 📦 Lightweight - Only 15KB gzipped (including GSAP)

📦 Installation

npm install @stianlarsen/react-light-beam

That's it! GSAP is included automatically. ✨


🚀 Quick Start

import { LightBeam } from "@stianlarsen/react-light-beam";

function App() {
  return (
    <div style={{ position: "relative", minHeight: "200vh" }}>
      <LightBeam
        colorDarkmode="rgba(255, 255, 255, 0.8)"
        colorLightmode="rgba(0, 0, 0, 0.2)"
        fullWidth={0.8}
      />
      <YourContent />
    </div>
  );
}

📖 Table of Contents


🎛️ Core Props

Basic Configuration

| Prop | Type | Default | Description | |------|------|---------|-------------| | colorLightmode | string | "rgba(0,0,0, 0.5)" | Beam color in light mode | | colorDarkmode | string | "rgba(255, 255, 255, 0.5)" | Beam color in dark mode | | fullWidth | number | 1.0 | Maximum beam width (0-1) | | invert | boolean | false | Invert scroll direction | | maskLightByProgress | boolean | false | Fade beam as user scrolls | | className | string | - | Custom CSS classes | | style | CSSProperties | - | Inline styles override | | scrollElement | EventTarget | document.body | Element to attach scroll listener | | onLoaded | () => void | - | Callback when component mounts | | disableDefaultStyles | boolean | false | Disable all default inline styles |


💫 Atmospheric Effects (NEW)

Add depth and dimension with optional atmospheric effects:

Dust Particles

Floating particles that drift through the beam.

<LightBeam
  dustParticles={{
    enabled: true,
    count: 50,              // Number of particles
    speed: 1.2,             // Animation speed multiplier
    sizeRange: [1, 3],      // Min/max size in pixels
    opacityRange: [0.2, 0.6], // Min/max opacity
    color: "rgba(255, 255, 255, 0.8)" // Optional (inherits beam color)
  }}
/>

Mist Effect

Volumetric fog atmosphere with depth.

<LightBeam
  mist={{
    enabled: true,
    intensity: 0.4,    // Opacity/thickness (0-1)
    speed: 1,          // Animation speed multiplier
    layers: 3          // More layers = more depth
  }}
/>

Pulse Effect

Rhythmic breathing animation.

<LightBeam
  pulse={{
    enabled: true,
    duration: 2.5,          // Seconds per pulse cycle
    intensity: 0.3,         // Pulse strength (0-1)
    easing: "sine.inOut"    // GSAP easing function
  }}
/>

Combine All Effects

<LightBeam
  colorDarkmode="rgba(255, 255, 255, 0.8)"
  fullWidth={0.8}
  dustParticles={{ enabled: true, count: 50 }}
  mist={{ enabled: true, intensity: 0.4, layers: 3 }}
  pulse={{ enabled: true, duration: 2.5, intensity: 0.3 }}
/>

🎨 Styling Options

Option 1: CSS Variables (Recommended)

Override default styles using CSS variables:

<LightBeam className="custom-beam" />
.custom-beam {
  --react-light-beam-height: 800px;
  --react-light-beam-width: 80vw;
}

Available CSS Variables:

  • --react-light-beam-height (default: 500px)
  • --react-light-beam-width (default: 100vw)

Option 2: Inline Styles

<LightBeam
  style={{
    height: "800px",
    width: "80vw",
    marginTop: "-200px"
  }}
/>

Option 3: Full CSS Control

Disable default styles for complete control:

<LightBeam
  disableDefaultStyles={true}
  className="my-beam"
/>
.my-beam {
  height: 800px;
  width: 100%;
  position: absolute;
  /* Full control - you provide all styles */
}

🔧 Advanced Usage

Positioning

For best results, position the beam absolutely within a relative container:

<div className="hero-section">
  <LightBeam className="beam" />
  <YourContent />
</div>
.hero-section {
  position: relative;
  min-height: 100vh;
}

.beam {
  position: absolute;
  inset: 0;
  margin-top: -300px; /* Adjust to position beam above content */
  z-index: -1;
}

Custom Scroll Container

Attach to a specific scrollable element:

const scrollContainer = useRef(null);

<div ref={scrollContainer} style={{ height: "500px", overflow: "auto" }}>
  <LightBeam scrollElement={scrollContainer.current} />
  <YourContent />
</div>

Dark Mode Customization

The component auto-detects system preferences. Customize colors per mode:

<LightBeam
  colorLightmode="rgba(0, 0, 0, 0.2)"        // Subtle in light mode
  colorDarkmode="rgba(255, 255, 255, 0.8)"   // Vibrant in dark mode
/>

⚡ Performance

LightBeam is optimized for production:

| Metric | Value | |--------|-------| | Bundle Size | ~15KB gzipped (with GSAP) | | Frame Rate | Consistent 60fps | | Scroll Handler | <0.4ms per frame | | Memory | Minimal footprint | | CPU Usage | 30% less than alternatives |

Optimizations

  • ✅ CSS custom properties for minimal DOM updates
  • ✅ GPU-accelerated transforms
  • ✅ Debounced scroll events via GSAP
  • ✅ Lazy-loaded atmospheric effects
  • ✅ Tree-shakeable code
  • ✅ No layout thrashing

📚 Examples

Hero Section

function Hero() {
  return (
    <section className="hero">
      <LightBeam
        colorDarkmode="rgba(59, 130, 246, 0.5)"
        fullWidth={0.7}
        className="hero-beam"
        pulse={{ enabled: true, duration: 3, intensity: 0.2 }}
      />
      <h1>Welcome to the Future</h1>
      <p>Scroll to explore</p>
    </section>
  );
}

Landing Page with Effects

function Landing() {
  return (
    <div className="landing">
      <LightBeam
        colorDarkmode="rgba(139, 92, 246, 0.6)"
        fullWidth={0.9}
        maskLightByProgress={true}
        dustParticles={{ enabled: true, count: 40, speed: 0.8 }}
        mist={{ enabled: true, intensity: 0.3, layers: 2 }}
      />
      <YourLandingContent />
    </div>
  );
}

Multiple Beams

function MultiBeam() {
  return (
    <div className="container">
      <LightBeam
        id="beam-1"
        colorDarkmode="rgba(59, 130, 246, 0.5)"
        fullWidth={0.6}
      />
      <LightBeam
        id="beam-2"
        colorDarkmode="rgba(139, 92, 246, 0.3)"
        fullWidth={0.8}
        invert={true}
      />
      <YourContent />
    </div>
  );
}

📋 API Reference

Complete Props Table

| Prop | Type | Default | Description | |------|------|---------|-------------| | id | string | - | Unique ID for the container | | className | string | - | Custom CSS classes | | style | React.CSSProperties | - | Inline styles (merged with defaults) | | colorLightmode | string | "rgba(0,0,0, 0.5)" | Light mode beam color | | colorDarkmode | string | "rgba(255, 255, 255, 0.5)" | Dark mode beam color | | fullWidth | number | 1.0 | Maximum width (0-1) | | maskLightByProgress | boolean | false | Progressive mask fade | | invert | boolean | false | Invert scroll direction | | scrollElement | EventTarget | document.body | Scroll container | | onLoaded | () => void | - | Mount callback | | disableDefaultStyles | boolean | false | Disable inline styles | | dustParticles | DustParticlesConfig | { enabled: false } | Dust particles config | | mist | MistConfig | { enabled: false } | Mist effect config | | pulse | PulseConfig | { enabled: false } | Pulse effect config |

Type Definitions

type DustParticlesConfig = {
  enabled?: boolean;
  count?: number;              // Default: 30
  speed?: number;              // Default: 1
  sizeRange?: [number, number]; // Default: [1, 3]
  opacityRange?: [number, number]; // Default: [0.2, 0.6]
  color?: string;              // Default: inherits beam color
};

type MistConfig = {
  enabled?: boolean;
  intensity?: number;          // Default: 0.3 (0-1)
  speed?: number;              // Default: 1
  layers?: number;             // Default: 2
};

type PulseConfig = {
  enabled?: boolean;
  duration?: number;           // Default: 2 (seconds)
  intensity?: number;          // Default: 0.2 (0-1)
  easing?: string;             // Default: "sine.inOut"
};

📝 Changelog

v3.0.0 (2026-01-04)

  • NEW: Added atmospheric effects (dust particles, mist, pulse)
  • 🚀 BREAKING: GSAP now included as dependency (no manual install needed)
  • 📦 IMPROVED: One-command installation
  • 🎯 IMPROVED: Homepage now points to live demo
  • 🐛 FIXED: Removed duplicate dependencies
  • 📚 IMPROVED: Complete README rewrite with comprehensive docs

v2.1.1 (2026-01-04)

  • PERFORMANCE: Optimized scroll handler with CSS custom properties
  • 🐛 FIXED: Laggy scroll behavior with invert=true
  • 🐛 FIXED: CSS variable color parsing errors
  • 📈 IMPROVED: 60-80% reduction in scroll handler execution time

v2.0.0 (2026-01-04)

  • 🚀 BREAKING: Migrated from Framer Motion to GSAP ScrollTrigger
  • PERFORMANCE: 40% faster scroll performance
  • 🐛 FIXED: Bidirectional scrolling issues
  • 🐛 FIXED: Invert prop behavior
  • 🐛 FIXED: Color switching glitches on scroll direction change
  • 🎨 IMPROVED: Removed CSS transitions (GSAP handles animations)

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/stianalars1/react-light-beam.git
cd react-light-beam

# Install dependencies
npm install

# Build the package
npm run build

# Run the example locally
cd example
npm install
npm run dev

Open http://localhost:3000 to view the demo.

Testing Changes

# Build the package
npm run build

# Build the example
cd example && npm run build

# Test the static export
npx serve out

📄 License

MIT © Stian Larsen


🙏 Acknowledgments

  • GSAP - Industry-leading animation library
  • React - The library for web and native user interfaces
  • TypeScript - JavaScript with syntax for types

🔗 Links


Built with ❤️ using GSAP ScrollTrigger

⭐ Star this repo if you find it useful!