UI / Decor
Dot Lights
Digits and short text written in twinkling lights as a dot matrix, the way the 3D room puts the year up at New Year.
Installation
npx shadcn@latest add https://jiaweing.com/r/dot-lights.jsonWith the @jiaweing namespace set up, use @jiaweing/dot-lights in place of the URL.
Usage
tsx
import { DotLights } from "@/components/room/dot-lights";tsx
<div className="relative h-60 bg-slate-950">
<DotLights text="2027" />
</div>- It draws on a see-through canvas over its parent and takes no clicks.
- three.js is only fetched in the browser, the first time it is needed.
- With reduced motion, the lights stand in place without flying in.
Props
DotLights
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | - | Digits, A to Z, spaces and common marks, five dots wide and seven tall. Anything else is a gap. |
| ref | Ref<{ replay: () => void }> | - | replay() flies the lights out again. |
| trigger | unknown | - | Sets it off each time it becomes a new value that is not false, 0 or empty: a flag going true, or a count going up. |
| dotSize | number | 24 | The most pixels between two dots. Smaller when the text would not fit. |
| hold | number | - | Seconds before the lights fall away. Left out, they stay up. |
| colors | string[] | the 2026 gradient | Any CSS colours, oklch() and color-mix() included. |
| className | string | - | Classes on the layer. It lies over its parent, so give the parent a position. |
MIT licensed. Copy it, change it, ship it.