This library is not production-ready yet. Developers should use it with caution and expect breaking changes.

Lightning

Animated lightning bolt strikes with branching and flash effects.

Installation

First, make sure you have the base map component installed:

npx shadcn@latest add https://www.terrae.dev/map.json

Then install the lightning component:

npx shadcn@latest add https://www.terrae.dev/lightning.json

Custom Colors

Customize the lightning appearance with boltColor and flashColor. Create purple electrical storms, blue plasma bolts, or any color combination.

Manual Strike Control

Disable automatic strikes with autoStrike={false} and use the useLightningControl hook to trigger strikes programmatically. Perfect for user-triggered events or synchronized effects.

Lightning Storm

Create dramatic storm scenes by placing multiple lightning components with different strikeInterval values. Vary the size to create depth and randomness.

Properties

PropertyTypeDefaultDescription
idstringrequiredUnique identifier for the lightning effect
coordinates[number, number]requiredLightning location as [longitude, latitude]
sizenumber200Lightning bolt size in pixels
boltColorstring#ffffffLightning bolt color
flashColorstring#e0e8ffFlash effect color
flashIntensitynumber0.6Flash intensity (0-1)
autoStrikebooleantrueEnable automatic lightning strikes
strikeIntervalnumber4000Time in ms between strikes (min: 500)
boltWidthnumber4Width of the lightning bolt
branchProbabilitynumber0.3Probability of bolt branching (0-1)

Use Cases

Weather Visualization

Display active thunderstorms on weather maps

Gaming Maps

Add dramatic weather effects to game world maps