animated-list
eldoraui/animated-listFreeComponent
An animated list component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/animated-list.jsonSource
1"use client"23import React, { useEffect, useMemo, useState } from "react"4import { AnimatePresence, motion, useAnimationControls } from "motion/react"56import { cn } from "@/lib/utils"78type AnimationPhase = "idle" | "forming_column" | "scrolling_down" | "resetting"910type AnimatedListProps = {11 children: React.ReactNode12 className?: string13 stackGap?: number14 columnGap?: number15 scaleFactor?: number16 scrollDownDuration?: number17 formationDuration?: number18}1920type AnimatedListItemProps = {21 children: React.ReactNode22 className?: string23 index: number24 listLength: number25 stackGap?: number26 columnGap?: number27 scaleFactor?: number28}2930function InternalAnimatedListItem({31 children,32 className,33 index,34 listLength,35 animationPhase,36 onFormationComplete,37 stackGap = 10,38 columnGap = 100,39 scaleFactor = 0.1,40 formationDuration = 1,41 visibleItemsCount = 4,42 resetSpringStiffness = 120,43 resetSpringDamping = 20,44}: AnimatedListItemProps & {45 animationPhase: AnimationPhase46 onFormationComplete?: () => void47 formationDuration: number48 visibleItemsCount: number49 resetSpringStiffness: number50 resetSpringDamping: number51}) {52 const reverseIndex = listLength - 1 - index53 const isVisible = reverseIndex < visibleItemsCount54 const lastItemOffset = (listLength - 1) * columnGap55 const isLastItem = index === listLength - 15657 const itemVariants = {58 initial: {59 scale: 1 + index * scaleFactor,60 y: reverseIndex * stackGap,61 opacity: isVisible ? 1 : 0,62 },63 column: {64 scale: 1,65 y: index * columnGap - lastItemOffset,66 opacity: 1,67 },68 }6970 const target =71 animationPhase === "idle" || animationPhase === "resetting"72 ? "initial"73 : "column"7475 const getTransition = () => {76 if (animationPhase === "resetting") {77 return {78 type: "spring" as const,79 stiffness: resetSpringStiffness,80 damping: resetSpringDamping,81 }82 } else {83 return { duration: formationDuration, ease: [0.4, 0, 0.2, 1] as const }84 }85 }8687 const handleAnimationComplete = (definition: string) => {88 if (89 isLastItem &&90 definition === "column" &&91 animationPhase === "forming_column"92 ) {93 onFormationComplete?.()94 }95 }9697 return (98 <motion.div99 key={index}100 className={cn("absolute inset-x-0 flex w-full justify-center", className)}101 variants={itemVariants}102 initial="initial"103 animate={target}104 transition={getTransition()}105// … truncated
What it pulls in
npm packages
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep | |
| clerk-otpclerk-otp | eldoraui | Components | Free | 2 deps |
