Components
- Accordion
- Add to Cart
- Animated List
- Carousel
- Collapsible Sidebarnew
- Dynamic Island
- Expandable Cardnew
- Expanding Searchnew
- Filter Grid
- Kanban Board
- Layout Switcher
- Morphing Popover
- Number Flip
- Page Transition
- Product Gallery
- Segmented Control
- Sortable Table
- Stack Navigator
- Status Button
- Step Wizard
- Tabs
- Text Morphnew
- Theme Mode Switch
- Theme Morph Button
- Theme Toggle Button
- Theme Toggle Switch
- Theme Transition
- Toast Stacknew
Inbox 6
- Maya opened a pull requestfeat: keyboard shortcuts for the editor3m
- Deploy finishedProduction is live at v2.14.012m
- Jonas replied in #design“Can we ship this behind a flag?”26m
- New issue in productionTypeError in checkout/summary.tsx48m
- Payment receivedInvoice #1042 for $240.001h
- New team memberPriya joined the Acme workspace3h
Installation
$ pnpm dlx shadcn@latest add @transition-kit/animated-listUsage
import {
AnimatedList,
AnimatedListItem,
useAnimatedList,
} from "@/components/transitions/animated-list";const { items, add, remove, move, sort, set } = useAnimatedList([
{ id: 1, title: "Deploy finished" },
{ id: 2, title: "Payment received" },
]);
<AnimatedList aria-label="Notifications">
{items.map((item) => (
<AnimatedListItem key={item.id} id={item.id}>
{item.title}
<button type="button" onClick={() => remove(item.id)}>
Dismiss
</button>
</AnimatedListItem>
))}
</AnimatedList>;add({ id: 3, title: "New comment" }, 0); // insert at index 0 (default: end)
remove(2); // by id
move(1, 0); // move id 1 to index 0
sort((a, b) => a.title.localeCompare(b.title));
set((items) => items.filter((item) => !item.read)); // any updatestartTransition(() => setItems((items) => items.slice(1)));API Reference
AnimatedListItem
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | number | - | Unique identity for the row, stable between renders. Render it with the same key. |
useAnimatedList
| Return | Type | Description |
|---|---|---|
items | T[] | Current list contents. |
add | (item: T, index?: number) => void | Inserts an item at the index (default: end). |
remove | (id: string | number) => void | Removes the item with the given id. |
move | (id: string | number, index: number) => void | Moves the item with the given id to an index. |
sort | (compare: (a: T, b: T) => number) => void | Reorders items with a compare function. |
set | (items: T[] | ((items: T[]) => T[])) => void | Replaces items with an array or an updater function. |
const { items, add, remove, move, sort, set } = useAnimatedList(initial, {
getId,
});