Components

Animated List

An animated notification list for React and Tailwind CSS: new items fade in at the top while older ones glide down with Motion layout animations, and anything past the limit fades out. Great for notification feeds, activity logs and live landing-page demos, with polite screen reader announcements built in.

  • Layout animations
  • AnimatePresence popLayout
  • Max visible items
  • Auto stream hook
  • Live region
  • prefers-reduced-motion
  • New comment· just now

    Leo: “Ship it, looks great on mobile.”

  • New sign-up· just now

    maya@orbit.dev joined your workspace

  • Payment received· just now

    $249.00 from Northwind Labs

Installation

$ npx shadcn@latest add https://duskui.com/r/animated-list.json

Usage

notifications.tsx
import { AnimatedList } from "@/components/dusk/animated-list/animated-list"

type Notification = { id: string; title: string }

export function Notifications({ items }: { items: Notification[] }) {
  // Newest first. Every child needs a stable key.
  return (
    <AnimatedList max={5} announcePrefix="New notification:">
      {items.map((n) => (
        <div key={n.id} className="rounded-xl border p-3">
          {n.title}
        </div>
      ))}
    </AnimatedList>
  )
}

Examples

Add items yourself

Prepend to your own state and the list animates. Here a paused useListStream acts as a queue: its push adds the next item. Changing max animates items in or out.

No notifications yet. Add one.

    Activity feed

    Render an ordered list with as="ol" and restyle the gap through className. The stream pauses while the feed is off-screen.

    Activity

    1. Preview deployedfeat/bento · 18s
    2. Build #1284 succeededmain · 42s

    API Reference

    AnimatedList also accepts any ul / ol attribute. The file also exports useListStream(source, { interval, limit, initial, paused, loop }), which returns { items, push } with items as { id, item }, newest first, for demos and landing pages.

    PropTypeDefaultDescription
    childrenReactNode—Keyed elements, newest first. Each is wrapped in an <li>.
    maxnumber5How many items are visible. Older ones animate out.
    as"ul" | "ol""ul"List element to render.
    announcebooleantrueRead new items out through a polite live region.
    announcePrefixstring""Text read before each new item, e.g. "New notification:".
    itemClassNamestring—Classes for each <li> wrapper.

    Accessibility

    • It renders a real list (ul or ol with li), so screen readers report the item count.
    • New items are announced once, by their text, through a separate polite live region. The list itself is not live, so reordering and items leaving are silent.
    • Items present on the first render are not announced or animated, so the server and client render the same markup.
    • Exiting items are popped out of the layout immediately and nothing measures text, so the list never jumps. Give its wrapper a fixed height for zero page shift.
    • Auto-updating content should be pausable (WCAG 2.2.2): the demo uses useListStream's paused option with a button and pauses off-screen.
    • With prefers-reduced-motion items only fade; there is no sliding, scaling or layout motion.