Get started
Three steps to your first animation.
# click to continue
pnpm add astro-magic-move Two-step shorthand
The simplest way to animate between two code states.
---
import { MagicMove } from 'astro-magic-move'
// click to see the template
const before = `const data = fetch('/api')`
const after = `const data = await fetch('/api')
const json = await data.json()`
--- Multi-step transitions
Pass an array for more than two states.
---
// click to add more steps
const steps = [
`const x = 1`,
`const x = 1
console.log(x)`,
]
--- Trigger modes
Three ways to fire the animation.
<!-- click to see other triggers -->
<!-- auto-play on mount -->
<MagicMove
before={a}
after={b}
trigger="auto"
/> Drive it from your own code
Use trigger="none" and control steps via the element's .step property.
const el = document.querySelector('magic-move') CSS variable theming
Define --shiki-* variables to control syntax colors. Click through to see themes applied live.
/* github dark — click to cycle themes */
:root {
--shiki-foreground: #c9d1d9;
--shiki-token-keyword: #d2a8ff;
--shiki-token-string: #a5d6ff;
--shiki-token-function: #79c0ff;
--shiki-token-comment: #484f58;
--shiki-token-constant: #ff7b72;
--shiki-token-parameter: #ffa657;
}