Meteors
Also called meteor shower, shooting stars, or meteor effect
Thin streaks of light with bright heads that shoot diagonally across a dark card or hero at random intervals, like a meteor shower.
import { motion, useReducedMotion } from 'motion/react';
const ANGLE = 35; // degrees below horizontal, shared by every meteor
const TRAVEL = 700; // px along that angle
// Fixed values instead of Math.random() in render, so server and client match.
const METEORS = Array.from({ length: 16 }, (_, i) => ({
left: `${((i * 37) % 110) - 25}%`,
top: `${((i * 53) % 70) - 20}%`,
tail: 70 + ((i * 29) % 110),
duration: 3 + ((i * 7) % 6),
// A negative delay starts each meteor partway through its cycle.
delay: -((i * 1.3) % 8)
}));
export function Meteors() {
const reduceMotion = useReducedMotion();
if (reduceMotion) return null; // a still, empty sky
return (
<div
aria-hidden
className='pointer-events-none absolute inset-0 overflow-hidden'
>
{METEORS.map((meteor, i) => {
const loop = {
duration: meteor.duration,
delay: meteor.delay,
repeat: Infinity,
ease: 'linear'
} as const;
return (
// The wrapper sets the angle; the streak only moves along x.
<div
key={i}
className='absolute'
style={{
left: meteor.left,
top: meteor.top,
rotate: `${ANGLE}deg`
}}
>
{/* In flight for the first 40% of each cycle, then hidden, so the
meteors fire at uneven intervals. */}
<motion.div
initial={{ x: 0, opacity: 0 }}
animate={{ x: [0, TRAVEL, TRAVEL], opacity: [0, 1, 1, 0, 0] }}
transition={{
x: { ...loop, times: [0, 0.4, 1] },
opacity: { ...loop, times: [0, 0.04, 0.3, 0.4, 1] }
}}
>
<span
className='absolute right-0 h-px -translate-y-1/2 bg-linear-to-r from-transparent to-white'
style={{ width: meteor.tail }}
/>
<span className='absolute right-0 size-[3px] translate-x-1/2 -translate-y-1/2 rounded-full bg-white shadow-[0_0_8px_2px_rgb(255_255_255/0.5)]' />
</motion.div>
</div>
);
})}
</div>
);
}Add a meteor shower behind the dark launch card: 16 thin streaks angled 35° down to the right, each a 1px line 70 to 180px long that fades from a 3px glowing white head to transparent at the tail. Start each at a random point along the top and left edges, move it about 700px along its angle with linear timing, and fade it out near the end. Give each a random 3 to 8s cycle that is in flight for 40% of the time, plus a random negative delay, so they fire at uneven intervals. Animate only transform and opacity, keep them behind the content, and show a still sky when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
Meteors explained
A meteor effect sends short streaks of light across a dark surface at an angle. Each streak has a small glowing head and a tail that fades out behind it, and they start at different places and times, so the scene looks like a clear night with shooting stars. It shows up behind launch announcements, dark pricing cards, and space-themed heroes.
Each meteor is a thin element with a gradient tail, rotated to a shared angle and moved along its own length with a transform animation. Give every meteor its own start point, duration, and negative animation-delay, and spend only part of each cycle in flight, so they fire at uneven intervals and never settle into a visible rhythm.
Keep the count modest, 10 to 20 at a time, and keep the streaks behind the content with pointer-events: none and aria-hidden. Check that text stays readable when a bright head crosses it. Under prefers-reduced-motion, show a still sky.
Often confused with
- Particle background
- A particle background drifts dots slowly in every direction. Meteors are quick streaks that all travel at one angle and vanish.
Related terms
All termsParticle background
A backdrop of small dots that drift slowly, often linked by faint lines when they pass close to each other, behind a hero or sign-in screen.
Warp background
A tunnel of grid walls receding to a vanishing point, with streaks of light racing along them, that frames a card in the middle.
Delay
The wait between the moment an animation is triggered and the moment it starts moving, used to sequence motion or ignore brief triggers.
Looping animation
An animation that plays more than once, either a set number of times or forever, set in CSS with animation-iteration-count.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.