src/main.tsx
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App'
import './styles.css'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
Online Motion playground with React, TypeScript, spring animations, gestures, layout transitions, editable project files, and instant live preview.
Choose a source file from the explorer and edit it with Monaco.
Edit package.json to add browser-compatible npm packages or change versions. Preview packages load from esm.sh. Successful previews save resolved versions for ranges and tags with your draft and shares; change the range to resolve again. Scripts and build plugins run only in downloaded projects.
Auto-run updates the browser preview as you type. Turn it off to run your changes manually.
Use the console for browser logs and errors, or evaluate a command against the preview.
Share creates a snapshot link. Download exports the source so you can continue locally.
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App'
import './styles.css'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
import { useState } from 'react'
import { AnimatePresence, motion } from 'motion/react'
import { MotionCard, type MotionDemo } from './components/MotionCard'
const demos: MotionDemo[] = [
{ id: 'springs', label: 'Springs', value: '0.42s', detail: 'Natural, interruptible movement', tone: 'violet' },
{ id: 'layout', label: 'Layout', value: '12', detail: 'Shared layout transitions', tone: 'cyan' },
{ id: 'gestures', label: 'Gestures', value: '4', detail: 'Hover, tap, focus and drag', tone: 'lime' },
]
export default function App() {
const [filter, setFilter] = useState<'All' | 'Core'>('All')
const [replay, setReplay] = useState(0)
const visibleDemos = filter === 'All' ? demos : demos.slice(0, 2)
return (
<main className="app-shell">
<nav className="topbar">
<a className="brand" href="#top" aria-label="Motion lab home">
<span className="brand-mark" aria-hidden="true">M</span>
Motion lab
</a>
<span className="runtime"><i /> React runtime live</span>
</nav>
<section className="hero" id="top">
<div className="hero-copy">
<motion.p
className="eyebrow"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
>
MOTION FOR REACT
</motion.p>
<motion.h1
initial={{ opacity: 0, y: 18 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.08 }}
>
Make interfaces<br />feel <em>alive.</em>
</motion.h1>
<motion.p
className="hero-description"
initial={{ opacity: 0, y: 18 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.16 }}
>
Build fluid gestures, spring animations and layout transitions with a declarative React API.
</motion.p>
<div className="hero-actions">
<motion.button
className="primary-button"
whileHover={{ scale: 1.03 }}
whileTap={{ scale: 0.96 }}
onClick={() => setReplay((value) => value + 1)}
>
Replay animation <span aria-hidden="true">↗</span>
</motion.button>
<span className="install-command">npm install motion</span>
</div>
</div>
<div className="stage" aria-label="Interactive spring animation">
<div className="stage-grid" />
<AnimatePresence mode="wait">
<motion.div
key={replay}
className="orbital"
initial={{ opacity: 0, scale: 0.55, rotate: -35 }}
animate={{ opacity: 1, scale: 1, rotate: 0 }}
exit={{ opacity: 0, scale: 1.15, rotate: 20 }}
transition={{ type: 'spring', stiffness: 170, damping: 17 }}
>
<motion.div
className="orbit orbit-one"
animate={{ rotate: 360 }}
transition={{ duration: 10, repeat: Infinity, ease: 'linear' }}
>
<span />
</motion.div>
<motion.div
className="orbit orbit-two"
animate={{ rotate: -360 }}
transition={{ duration: 14, repeat: Infinity, ease: 'linear' }}
>
<span />
</motion.div>
<motion.div
className="core"
animate={{ scale: [1, 1.08, 1] }}
transition={{ duration: 2.4, repeat: Infinity, ease: 'easeInOut' }}
>
motion
</motion.div>
</motion.div>
</AnimatePresence>
<span className="stage-label">SPRING · STIFFNESS 170</span>
</div>
</section>
<section className="demo-section" aria-labelledby="demo-title">
<header className="section-heading">
<div>
<p className="eyebrow">BUILDING BLOCKS</p>
<h2 id="demo-title">Animation primitives</h2>
</div>
<div className="filter" aria-label="Filter animation primitives">
{(['All', 'Core'] as const).map((option) => (
<button
key={option}
className={filter === option ? 'active' : ''}
onClick={() => setFilter(option)}
>
{option}
</button>
))}
</div>
</header>
<motion.div className="card-grid" layout>
<AnimatePresence mode="popLayout">
{visibleDemos.map((demo, index) => (
<MotionCard key={demo.id} demo={demo} index={index} />
))}
</AnimatePresence>
</motion.div>
</section>
</main>
)
}
The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Edit a source file from the project explorer — the live preview recompiles automatically.
Add, rename, duplicate or delete project files as needed. Update affected imports after renaming or moving a file.
Use the console for logs and errors, and Format to tidy the active file.
Share the complete project or download a Vite project ZIP with its source files and package.json.
Motion 13
React 19 + TypeScript
Spring Animations
Hover and Tap Gestures
Layout Transitions
AnimatePresence
Local Component Imports
Live Preview
Vite Project Export
Local Runtime — No CDN
Auto-run updates the preview as you type. Turn it off to run manually with Run or Ctrl/⌘ + Enter.
The Console prompt can inspect browser globals and the rendered DOM, but not variables scoped inside ES modules or component state.
Console shortcuts apply when its prompt is focused. Editor shortcuts apply inside the code editor.
Code runs in a sandboxed browser preview, without Node.js, a backend, or private environment variables.
Download the project when you need build plugins, server APIs, native modules, or a production dependency workflow.