Installation
Usage
import { Relight } from "@/components/relight"
export function Hero() {
return (
<Relight text="Forge." y={0.42} className="flex min-h-[32rem] flex-col items-center justify-end px-6 pb-12 text-center">
<p className="text-muted-foreground">Move the light.</p>
</Relight>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | "Forge." | The word raised in metal, in your page's font. Also real text on the page, for screen readers and search engines. |
| src | string | — | A photo or logo to raise instead (same origin or served with CORS): its bright parts stand out. |
| colors | [string, string] | ["var(--background)", "var(--primary)"] | The ground, then the metal's warm colour. Any CSS colour. |
| depth | number | 1 | How far the metal stands out, 0.5–2. |
| shine | number | 0.6 | How polished it is, 0 (satin) to 1 (mirror). |
| size | number | 1 | Reach of the light, 0.5–1.6. |
| y | number | 0.45 | Where the word sits, from 0 (top) to 1 (bottom). |
| autoplay | boolean | true | When nobody is near, the light circles slowly over the metal. |
| interactive | boolean | true | The light follows the pointer on a spring; pressing brings it closer. |
| moment | number | — | Holds the light still where it circles to at this moment, in seconds. |
| captureRef | Ref<RelightHandle> | — | capture(width, height) resolves a PNG at any size. |
| ...props | HTMLAttributes<HTMLDivElement> | — | Children sit above the metal and stay interactive. |
Accessibility
- The word 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.
- With prefers-reduced-motion the light rests above the word and the pointer is ignored.
- 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 word without the lighting.
Changelog
- v1.0.0Latest
First release.