Light Text

Hollow lettering with a light behind it. Beams pour out through the letters, can reach toward your pointer, with a fine noise texture. Follows your theme.

Props
Variant
Light
theme
Background
theme
Intensity0.70
Ray length0.21
Spread0.55
Noise0.07
Face0.85
Outline width3.0
Weight900
Drift0.50

Installation

pnpm dlx shadcn@latest add @breeze/light-text

Usage

import { LightText } from "@/components/breeze/light-text"

Give it a box; the lettering fits itself to the box's height and width.

<LightText text="BREEZE" className="h-[360px] w-full" />

Use \n for more than one line:

<LightText text={"LIGHT\nLEAKS"} className="h-[480px] w-full" />

Theme

By default the light is your --foreground colour on your --background, so it switches with the theme: bright beams pouring out of the dark in dark mode, and dark beams streaming across the page in light mode, like shadows through the letters. Pass color and background to fix them, for example a white light on black in both themes:

<LightText color="#ffffff" background="#060607" />

Variants

  • solid: the letters glow and the beams pour out of them.
  • outline: hollow letters. Only the outlines let light through, so the beams escape from the edges and corners. outlineWidth sets how thick they are.

The light

The light sits behind the text at lightX/lightY and wanders a little on its own (drift; 0 holds it still). The beams reach toward your pointer, easing after it, then settle back when it leaves. Pass followPointer={false} to keep the light still.

<LightText variant="outline" followPointer={false} lightY={0.2} />

Under the hood, every pixel looks back toward the light and adds up whatever leaks through the letters, which is what makes the beams fan out. rayLength sets how far they reach, spread how wide they fan, and intensity how bright they are.

Props

PropTypeDefaultDescription
textstring"BREEZE"The words; \n starts a new line
variant"solid" | "outline""solid"Glowing letters, or hollow outlines
colorstring"var(--foreground)"Light colour, any CSS colour or var()
backgroundstring"var(--background)"Backdrop colour, or "transparent"
intensitynumber0.7Brightness of the beams
rayLengthnumber0.210 to 1, how far the beams reach
spreadnumber0.55How far the beams fan out
noisenumber0.070 to 1, a still noise texture over the whole image
faceBrightnessnumber0.850 to 1, brightness of the letters themselves
outlineWidthnumber3Outline thickness in px (outline variant)
weightnumber900Font weight
fontFamilystringGeistAny CSS font-family, var() works
scalenumber0.62Text height as a share of the box (it also fits the width)
followPointerbooleantrueThe beams reach toward the pointer
lightXnumber0.5Resting light position across, 0 to 1
lightYnumber0.5Resting light position down, 0 to 1
driftnumber0.5How much the light wanders on its own

The text uses Geist, a sharp grotesk, unless you pass fontFamily. The canvas has role="img" and the text as its label for screen readers. It pauses off-screen and in hidden tabs, and with reduced motion it renders a single still frame.