# Stage Light

> A cone of light from above that sways gently and turns to follow the pointer.

Category: Backgrounds · Free · Updated 2026-10-20 · Live demo: https://www.motionkitui.com/components/stage-light

## When to use it

Product reveals, award and event pages, and dramatic hero sections.

## How it works

A cone of light, a conic gradient faded out by a linear mask, hangs from the top centre and sways on an idle loop. When the pointer is over the area, the beam's angle is set from the lamp towards the pointer through a soft spring, and the sway pauses until the pointer leaves.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/stage-light.json
```

Or copy `components/motionkit/stage-light.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `width` | `number` | `50` | Width of the light cone in degrees. |
| `sway` | `number` | `12` | How far the beam sways either side, in degrees. |
| `duration` | `number` | `6` | Seconds for one sway from side to side. |
| `follow` | `boolean` | `true` | Turn the beam toward the pointer while it is over the area. |
| `color` | `string` | `"#5FAEB4"` | Colour of the light. |

## Accessibility

- **Keyboard: Not applicable.** A decorative background with nothing to focus.
- **Screen readers: Pass.** The beam and lamp are hidden from assistive tech.
- **Reduced motion: Partial.** The beam holds still and ignores the pointer for reduced-motion users. It loops forever otherwise, so if it sits beside other content for more than 5 seconds, WCAG 2.2.2 asks you to add a pause control.
- **Colour contrast: Partial.** The beam moves behind your content, so contrast varies. Test your text where the light is brightest.

## Source

```tsx
"use client";

import { useEffect, useState, type PointerEvent, type ReactNode } from "react";
import { animate, motion, useMotionValue, useReducedMotion, useSpring } from "motion/react";

type StageLightProps = {
  children?: ReactNode;
  /** Width of the light cone in degrees. */
  width?: number;
  /** How far the beam sways either side, in degrees. */
  sway?: number;
  /** Seconds for one sway from side to side. */
  duration?: number;
  /** Turn the beam toward the pointer while it is over the area. */
  follow?: boolean;
  /** Colour of the light. */
  color?: string;
  className?: string;
};

export function StageLight({
  children,
  width = 50,
  sway = 12,
  duration = 6,
  follow = true,
  color = "#5FAEB4",
  className = "",
}: StageLightProps) {
  const reduceMotion = useReducedMotion();
  const [aiming, setAiming] = useState(false);
  const rotate = useMotionValue(0);
  const smoothRotate = useSpring(rotate, { stiffness: 60, damping: 18 });

  // idle sway, paused while the beam is following the pointer
  useEffect(() => {
    if (reduceMotion || aiming) return;
    const controls = animate(rotate, [-sway, sway], { duration, repeat: Infinity, repeatType: "mirror", ease: "easeInOut" });
    return () => controls.stop();
  }, [rotate, sway, duration, reduceMotion, aiming]);

  function handlePointerMove(event: PointerEvent<HTMLDivElement>) {
    if (!follow || reduceMotion) return;
    const rect = event.currentTarget.getBoundingClientRect();
    // angle from the light source (top centre) to the pointer; clockwise rotation swings the beam left
    const dx = event.clientX - (rect.left + rect.width / 2);
    const dy = Math.max(event.clientY - rect.top, 1);
    const degrees = (-Math.atan2(dx, dy) * 180) / Math.PI;
    rotate.set(Math.max(-45, Math.min(45, degrees)));
    if (!aiming) setAiming(true);
  }

  return (
    <div
      onPointerMove={handlePointerMove}
      onPointerLeave={() => setAiming(false)}
      className={`relative isolate overflow-hidden bg-[#0C1010] ${className}`}
    >
      <motion.div
        aria-hidden
        className="absolute -inset-x-1/2 top-0 -z-10 h-[160%] opacity-40"
        style={{
          rotate: smoothRotate,
          originY: 0,
          // a cone pointing straight down from the top centre
          background: `conic-gradient(from ${180 - width / 2}deg at 50% 0%, transparent, ${color} ${width / 2}deg, transparent ${width}deg)`,
          maskImage: "linear-gradient(to bottom, black, transparent 70%)",
        }}
      />
      {/* the lamp itself */}
      <div
        aria-hidden
        className="absolute left-1/2 top-0 -z-10 h-0.5 w-1/4 -translate-x-1/2 rounded-full"
        style={{ backgroundColor: color, boxShadow: `0 0 30px 6px ${color}` }}
      />
      {children}
    </div>
  );
}
```
