A string of glass bulbs hung on a real catenary along the top of a panel: each throws a small pool of coloured light, the hand swings the wire and a click unscrews a bulb.
Wrap a panel: the lights take a 56 px band at its top. Switching on or off runs along the wire and a click unscrews a bulb (onBulbToggle). The default warm preset is still at rest; chase and twinkle add a slow ambient loop.
When not to use
Do not leave it on all year or put it on error and payment screens. It is a seasonal decoration; use a static banner or Alert for a notice that needs attention.
Use it for the season on a working surface: a rota panel, a settings card, an app header, a
holiday notice. The lights hang in their own band above the content and never cover it, so the
panel stays usable all December. Effects are visual pieces rather than controls: they do not
replace the Interface components in dashboards and forms.
Wrap the panel. The lights take a 56 px band (band) at its top, and your content starts under it.
import { StringLights } from "@/components/effects/string-lights"export function HolidayRota() { return ( <StringLights className="overflow-hidden rounded-2xl border bg-card"> <div className="px-6 pb-6">{/* your panel */}</div> </StringLights> )}
The pools of light blend with the wrapper's own background, so give the wrapper one (bg-card
above). With placement="overlay" no band is added: the lights hang in your own top padding.
Without children the layer fills the top of its positioned parent; give the parent
relative isolate.
on is controlled (or defaultOn). Switching runs along the wire one bulb at a time: the
filament warms dull orange, jumps to its colour, sits a little over-bright and rests.
A click on a bulb unscrews it a quarter turn and it goes dark; a second click lights it.
onBulbToggle(index, lit) reports each click. A click on a dark string lights it, and
unscrewing the last lit bulb switches it off; both go through onOnChange. Set
interactive={false} for a purely decorative string.
chase: your palette, with a slow wave of brightness travelling the wire (9 s period).
twinkle: single bulbs dim and return on a seeded schedule, never more than two at once.
temperament (calm, lively, playful) scales the swing and the switching run. bulbs
(default one every 56 px), swags (one drape every 300 px) and sag tune the string.
active={false} removes the lights, the band and the loop, for example outside the season.
Any CSS colours, repeated along the wire. The default palette is your primary, secondary and
chart-1 to chart-3. A bulb cannot glow dark: lightness is lifted, chroma is capped and
neutral colours (a near-black primary, a grey secondary) light up as warm white.
The wire, pins and pools are aria-hidden and pointer-events: none. Only the bulbs take
clicks, and only when interactive is true.
The bulbs are one tab stop (a group named "String lights"): arrow keys, Home and End move
between bulbs, Enter and Space unscrew or relight the focused one. Each is a toggle button
(aria-pressed).
The pools are clamped against your page: at mount the component reads the background and the
text colours (foreground, muted-foreground) and lowers each pool's alpha until the text
under it keeps a 4.5:1 contrast (or no worse than it already was). The concept's 22% only
applies inside the empty band.
On touch screens a finger brushes the wire; there is no automatic hand. Vertical scrolling stays
with the page.
The string hangs still with every bulb lit at rest; no swing, no chase or twinkle. Switching and
unscrewing fade in 120 ms. The hooks read usePrefersReducedMotion, so the MotionKitProvider
setting applies too.
One SVG path for the wire and plain elements for the bulbs; each frame writes transforms and
opacities only, with a damped chain of a few dozen nodes.
The loop stops off screen and in hidden tabs. With warm it also sleeps once the wire is at rest
and wakes when the hand comes back; chase and twinkle are slow ambient loops.
Source size is checked against the 15 KB gzip budget for effects (pnpm size).
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom.
Dependencies
motion
Triggers
pointer movement, click, ambient loop (pauses off screen and in hidden tabs)
Reduced motion
The string hangs still with every bulb lit at rest; no swing, no chase or twinkle, and switching fades in 120 ms.
Keyboard
Tab
Focus the string (one tab stop)
Arrow keys / Home / End
Move between bulbs
Enter / Space
Unscrew or relight the focused bulb
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)