Slide-in animations in tw-animate-css
Slide classes move an element in from a direction as it enters. You can slide the full 100% or give a smaller value.
How it works
- Choose a direction. Each tile uses a
slide-in-from-*class:top,bottom,leftorright. All tiles also haveanimate-inandfade-in. [1] - Set the distance.
slide-in-from-lefthas no value and slides the full 100%. The others add a number, such asslide-in-from-top-8. [1] - Replay all tiles. The grid uses the
runcounter as itskey, so pressing Replay mounts all four tiles again and the slides restart. [1]
Run and edit it
It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.
import { useState } from 'react';
// Full class names so Tailwind can find them
const tiles = [
{ label: 'from top (8)', cls: 'slide-in-from-top-8 bg-rose-500' },
{ label: 'from bottom (8)', cls: 'slide-in-from-bottom-8 bg-amber-500' },
{ label: 'from left (100%)', cls: 'slide-in-from-left bg-emerald-500' },
{ label: 'from right (12)', cls: 'slide-in-from-right-12 bg-sky-500' },
];
export default function App() {
const [run, setRun] = useState(0);
return (
<div className='flex h-[380px] flex-col items-center justify-center gap-5 overflow-hidden bg-slate-50'>
<div key={run} className='grid grid-cols-2 gap-4'>
{tiles.map((t) => (
<div
key={t.label}
className={`animate-in fade-in duration-700 ${t.cls} flex h-24 w-48 items-center justify-center rounded-lg font-medium text-white`}
>
{t.label}
</div>
))}
</div>
<button
onClick={() => setRun(run + 1)}
className='rounded-md bg-slate-900 px-4 py-2 text-sm text-white'
>
Replay
</button>
</div>
);
}
Each tile slides from a different side; press Replay to see them again. Code written by AgentGid [1].
Each tile slides from a different side; press Replay to see them again. Code written by AgentGid [1].Checked Oct 17, 2026: it starts without errors in Chromium with tw-animate-css 1.4.0, react 19.3.1, react-dom 19.3.1, tailwindcss 4.3.3. Needs WebGL.
More tw-animate-css examples
Exit animations with data-state in tw-animate-css Staggered delays in tw-animate-css Looping animations in tw-animate-css Enter animations in tw-animate-css
Sources
Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.