Animated list example

Updates that keep their place.

Insert, reorder and remove keyed rows while retaining input state and a useful focus destination.

Complete React client module · MIT · Next.js and Vite

Interactive example

Updates that keep their place

Insert, reorder and remove keyed rows while retaining input state and a useful focus destination.

Keyboard

  • Tab reaches each row action.
  • Removing the focused row moves to its nearest remaining neighbour.

States covered

  • keyed items
  • interrupted reorder
  • empty
  • reduced motion

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-motion-list-updates.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {AnimatedList,Button,Input} from '@bld8/ui';
const seed=[{id:'one',title:'Keyboard review'},{id:'two',title:'Release notes'},{id:'three',title:'Form patterns'}];
export default function Updates(){const [items,setItems]=useState(seed),[serial,setSerial]=useState(4);return <section><h3>Recent updates</h3><div className="actions"><Button onClick={()=>{setItems(previous=>[{id:String(serial),title:'New update '+serial},...previous]);setSerial(previous=>previous+1);}}>Add update</Button><Button variant="secondary" onClick={()=>setItems(previous=>[...previous].reverse())}>Reverse order</Button></div><AnimatedList label="Recent updates" items={items} getKey={item=>item.id} empty="No updates yet.">{item=><div style={{display:'flex',alignItems:'center',gap:12,padding:12,background:'var(--bui-surface)',borderRadius:4}}><input type="hidden" name={item.id} value={item.id}/><Input aria-label={'Title for '+item.id} defaultValue={item.title}/><Button variant="ghost" onClick={()=>setItems(previous=>previous.filter(value=>value.id!==item.id))} aria-label={'Remove '+item.title}>Remove</Button></div>}</AnimatedList></section>;}