Components / Data
Animated List
A live feed that pops new items in on top and pushes older ones down. Perfect for notifications.
💸
Payment received · now
$240 from Sam
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/animated-list.tsx. - 3
Use it
example.tsximport { AnimatedList } from "@/components/ui/animated-list"; const notifications = [ { icon: "💸", title: "Payment received", desc: "$240 from Sam", time: "now", bg: "bg-emerald-500/15" }, { icon: "👤", title: "New follower", desc: "Jordan followed you", time: "1m", bg: "bg-sky-500/15" }, { icon: "💬", title: "New message", desc: "Hey! Love the new design", time: "3m", bg: "bg-fuchsia-500/15" }, { icon: "🚀", title: "Deploy succeeded", desc: "haierui.dev is live", time: "5m", bg: "bg-orange-500/15" }, ]; export default function AnimatedListDemo() { return ( <div className="h-72 w-full max-w-sm overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]"> <AnimatedList items={notifications.map((n) => ( <div key={n.title} className="flex items-center gap-3 rounded-2xl border border-zinc-200 dark:border-white/10 bg-white/90 dark:bg-zinc-900/90 p-3"> <span className={`grid size-10 shrink-0 place-items-center rounded-xl text-lg ${n.bg}`}>{n.icon}</span> <div className="min-w-0 flex-1"> <p className="text-sm font-medium text-zinc-900 dark:text-white"> {n.title} <span className="font-normal text-zinc-500">· {n.time}</span> </p> <p className="truncate text-sm text-zinc-600 dark:text-zinc-400">{n.desc}</p> </div> </div> ))} /> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | ReactNode[] | — | Items to reveal, newest on top. Loops. |
| interval | number | 2000 | Milliseconds between new items. |
| maxVisible | number | 4 | Most items shown at once. |