Meteors
Meteors renders a shower of meteors streaking across its parent container. Positions, delays and durations are generated server-side, so the whole effect is pure CSS and ships zero JavaScript. Drop it behind a dark hero or card to add motion without touching your bundle.
Basic Meteors
The component fills its nearest relative
ancestor, so give the container relative
and overflow-hidden. Content inside the same container needs
relative
too, otherwise it sits underneath the meteor layer. The layer is decorative: it renders with
aria-hidden
and meteors are hidden for users who opt out of animation via prefers-reduced-motion.
Ship faster with Petal
Density and Seed
count
controls how many meteors render. Positions are deterministic for a given seed,
so LiveView re-renders never make the meteors jump. When rendering several meteor fields on
one page, give each a different seed
so they don't share the same scatter pattern.
count: 10, seed: 1
count: 40, seed: 2
Direction and Colour
New in 4.4.0: angle
points the shower anywhere (the default streaks down-left), color
tints the meteors and their trails, and reverse
mirrors the whole field so meteors stream the other way.
color: sky
reverse
Hero Example
Meteors read best on near-black panels. Here's a fuller hero: heading, subtitle and a call to
action sitting on a relative wrapper above the shower.
Build your next SaaS with Petal
Phoenix, LiveView and Tailwind, wired together so you can get straight to shipping the actual product.
Properties
| Attribute | Type | Default | Description |
|---|---|---|---|
angle
|
string |
"215deg"
|
direction the meteors travel, as a CSS angle (default streaks down and to the left) |
class
|
any |
nil
|
extra classes for the container |
color
|
string |
"#64748b"
|
meteor and trail colour. Any CSS colour; the default slate suits dark panels |
count
|
integer |
20
|
number of meteors |
rest
|
global |
||
reverse
|
boolean |
false
|
mirror the shower horizontally, so meteors stream the opposite way |
seed
|
integer |
0
|
vary this when rendering several meteor fields on one page so each gets a different scatter pattern |