Installation
Usage
import { LightTrail } from "@/components/light-trail"
export function Hero() {
return (
<LightTrail text="Light follows your hand." variant="neon" className="flex min-h-[32rem] flex-col items-center justify-end px-6 pb-12 text-center">
<p className="text-muted-foreground">Move your pointer across the headline.</p>
</LightTrail>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | "Light follows your hand." | The headline the light passes over, in your page's font, up to three lines. Also real text on the page. |
| variant | "neon" | "glass" | "ember" | "neon" | Light that shifts colour, clear glass that bends the letters, or embers with rising sparks. |
| colors | string[] | — | Colours the light cycles through (neon and ember). Leave it out for the full spectrum or fire. |
| width | number | 1 | Thickness of the trail, 0.5–2. |
| length | number | 1 | How long the trail lingers, 0.5–2. |
| y | number | 0.5 | Where the headline sits, from 0 (top) to 1 (bottom). |
| autoplay | boolean | true | When nobody is pointing, the light draws loops on its own. |
| interactive | boolean | true | The light follows the pointer or a finger. |
| moment | number | — | Holds the picture as the trail stands at this moment of its loops, in seconds. |
| captureRef | Ref<LightTrailHandle> | — | capture(width, height) resolves a PNG at any size: wallpapers, social cards, a 4K hero. |
| ...props | HTMLAttributes<HTMLDivElement> | — | Children sit above the picture and stay interactive. |
Accessibility
- The headline is real text in the page (visually hidden), so screen readers and search engines read it; the canvas and its still are decorative and hidden from assistive technology.
- On a light background the light tints like ink and on a dark one it glows, so the headline keeps its contrast in both themes.
- With prefers-reduced-motion it holds one still moment of its loops and ignores the pointer.
- It pauses off-screen and in hidden tabs, and frees its GPU memory when removed.
- Without WebGL2, on a software renderer, or on a device that can't hold a smooth frame rate, it shows the headline without the effect.
Changelog
- v1.0.0Latest
First release.