Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
A meteor shower with a consistent travel angle and container-relative spawn positions.
meteors
meteors-example.svelte
<script lang="ts"> import { Meteors } from "$lib/components/magic/meteors/index.js";</script>
<div class="bg-background relative flex h-64 w-full max-w-lg items-center justify-center overflow-hidden rounded-lg border"> <Meteors number={20} angle={215} minDuration={3} maxDuration={6} /> <p class="text-foreground relative z-10 text-4xl font-medium">meteors</p></div>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/meteors.json
Copy the Source Code
Copy and paste the following code into your project:
meteors.svelte
<script lang="ts"> import type { ClassValue } from "svelte/elements"; import { cn } from "#lib/utils.js"; import { onMount } from "svelte";
interface Props { number?: number; minDelay?: number; maxDelay?: number; minDuration?: number; maxDuration?: number; angle?: number; class?: ClassValue; }
let { number = 20, minDelay = 0.2, maxDelay = 1.2, minDuration = 2, maxDuration = 10, angle = 215, class: className, }: Props = $props();
type MeteorStyle = { angle: string; top: string; left: string; animationDelay: string; animationDuration: string; };
let meteorStyles: MeteorStyle[] = $state([]);
let updateMeteors = () => { const styles = [...new Array(number)].map(() => ({ angle: angle + "deg", top: "-5%", left: `${Math.random() * 100}%`, animationDelay: Math.random() * (maxDelay - minDelay) + minDelay + "s", animationDuration: Math.floor(Math.random() * (maxDuration - minDuration) + minDuration) + "s", })); meteorStyles = styles; }; onMount(() => { updateMeteors(); });</script>
{#each meteorStyles as style, idx (idx)} <span style="--angle: {style.angle}; top: {style.top}; left: {style.left}; animation-delay: {style.animationDelay}; animation-duration: {style.animationDuration};" class={cn( "animate-meteor pointer-events-none absolute size-0.5 [transform:rotate(var(--angle))] rounded-full bg-zinc-500 shadow-[0_0_0_1px_#ffffff10] [animation-fill-mode:backwards] motion-reduce:hidden", className )} > <div class="pointer-events-none absolute top-1/2 -z-10 h-px w-12.5 -translate-y-1/2 bg-linear-to-r from-zinc-500 to-transparent" ></div> </span>{/each} index.ts
import Meteors from "./meteors.svelte";export { Meteors };Add Tailwind CSS
Add the following to your routes/layout.css file:
src/routes/layout.css
@theme inline { --animate-meteor: meteor 5s linear infinite;
@keyframes meteor { 0% { transform: rotate(var(--angle)) translateX(0); opacity: 1; } 70% { opacity: 1; } 100% { transform: rotate(var(--angle)) translateX(-500px); opacity: 0; } }}Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── meteors/ ├── meteors.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/meteors/llms.txt
Follow the guide's installation and usage instructions.Match the project's existing structure, imports, and styles.Keep changes scoped to the component and verify it works.Reply with a short bullet list of completed changes.Usage
<script lang="ts"> import { Meteors } from "#lib/components/magic/meteors/index.js";</script>
<div class="relative h-64 overflow-hidden"> <Meteors /></div>Props
Meteors
| Name | Type | Default | Description |
|---|---|---|---|
number | number | 20 | Number of meteors |
minDelay | number | 0.2 | Minimum delay in seconds before meteor animation starts |
maxDelay | number | 1.2 | Maximum delay in seconds before meteor animation starts |
minDuration | number | 2 | Minimum duration in seconds for meteor animation |
maxDuration | number | 10 | Maximum duration in seconds for meteor animation |
angle | number | 215 | Angle in degrees for meteor trajectory |
class | ClassValue | | Additional CSS classes for the meteors container |