Animated List
svelte-animations/animated-listFreeBlock
A component that animates list items with smooth layout transitions, revealing items one by one from top to bottom.
Install it
npx shadcn@latest add https://sv-animations.vercel.app/r/animated-list.jsonSource
1<script lang="ts">2 import { onMount } from "svelte";3 import { motion, AnimatePresence, createLayoutMotion } from "motion-sv";4 import { cn } from "$UTILS$";5 import type { Snippet } from "svelte";67 interface AnimatedListProps<T> {8 items: T[];9 class?: string;10 delay?: number;11 children: Snippet<[T, number]>;12 }1314 type AnimatedListPropsGeneric = AnimatedListProps<any>;1516 let { items, class: className, delay = 1000, children }: AnimatedListPropsGeneric = $props();1718 // Create layout motion for smooth layout animations19 const layout = createLayoutMotion(motion);20 const update = layout.update;2122 // Use a mutable state array instead of derived23 let itemsToShow = $state<any[]>([]);2425 onMount(() => {26 // Initialize with first item27 update.with(() => {28 itemsToShow = [items[0]];29 })();3031 let currentIndex = 0;3233 const interval = setInterval(() => {34 if (currentIndex < items.length - 1) {35 currentIndex++;36 // Use update.with to track layout changes37 update.with(() => {38 // Add new item at the beginning (top)39 itemsToShow = [items[currentIndex], ...itemsToShow];40 })();41 }42 }, delay);4344 return () => clearInterval(interval);45 });46</script>4748<div class={cn("flex flex-col items-center gap-4", className)}>49 <AnimatePresence mode="popLayout">50 {#each itemsToShow as item, i (item.id)}51 <layout.div52 initial={{ scale: 0, opacity: 0, y: -8 }}53 animate={{54 scale: 1,55 opacity: 1,56 y: 0,57 transition: { type: "spring", stiffness: 500, damping: 30 },58 }}59 exit={{60 scale: 0,61 opacity: 0,62 y: 8,63 transition: { duration: 0.18 },64 }}65 layout66 layoutDependency={itemsToShow.length}67 class="mx-auto w-full"68 >69 {@render children(item, i)}70 </layout.div>71 {/each}72 </AnimatePresence>73</div>
What it pulls in
npm packages
Files it writes
More from Svelte Animations
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Beamanimated-beam | Svelte Animations | Blocks | Free | 1 dep · 6 files | |
| Animated Circular Progress Baranimated-circular-progress-bar | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Gradient Textanimated-gradient-text | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Grid Patternanimated-grid-pattern | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Shiny Textanimated-shiny-text | Svelte Animations | Blocks | Free | no deps | |
| Animated Theme Toggleranimated-theme-toggler | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Arc Timelinearc-timeline | Svelte Animations | Blocks | Free | no deps · 3 files | |
| Aurora Textaurora-text | Svelte Animations | Blocks | Free | no deps · 2 files |
