Code magic move

Pro

A code block that animates between versions of a snippet: unchanged tokens glide to their new line and column, removed tokens fade and lift out, added tokens type in behind an accent caret. Step dots, arrow keys, and a sideways drag walk a tutorial or changelog through each change.

Live · keyboard ready
save-button.tsx
export function SaveButton() {
  return <button>Save</button>;
}
Use the left and right arrow keys to move between steps.
  • A docs page or landing section that teaches an API by building a snippet up step by step.
  • A changelog or upgrade guide that shows exactly what changed between versions of a config or call.
  • Use code-block for a single snippet someone will copy.
  • Use a proper diff view for large files or code review; this is for short snippets that fit on screen.

Installation

Pro source and install commands unlock with a Pro plan.

example.tsx
import { CodeMagicMove } from "@/components/arc/code-magic-move/code-magic-move"; const steps = [  { title: "Create the client", code: `const client = new Client();` },  { title: "Add your key", code: `const client = new Client({  apiKey: process.env.API_KEY,});` },  { title: "Send a request", code: `const client = new Client({  apiKey: process.env.API_KEY,}); await client.orders.list();` },]; export function QuickstartSection() {  return <CodeMagicMove steps={steps} filename="index.ts" language="ts" label="Quickstart" />;}

CodeMagicMove

A code block that moves between versions of a snippet. Words that stay glide to their new line and column, removed words lift away, and new code types in behind a caret while the block grows or shrinks to the new line count. Lines a step introduced carry a faint band with an accent hairline, the header counts lines added and removed, and step dots, arrow keys, or a sideways drag walk a tutorial or changelog through each change.

PropTypeDefaultDescription
steps{ code: string; title: string; description?: string; filename?: string }[]A four step save button tutorialThe versions of the snippet in order. title and description caption the step under the code; filename overrides the header for that step. Tabs become two spaces.
languagestring"tsx"Used for lightweight syntax highlighting in the same colors as code-block.
filenamestring"save-button.tsx"File name in the header when a step has none.
valuenumber–Index of the shown step for controlled use. Changing it moves to that step.
defaultValuenumber0Starting step when uncontrolled.
onValueChange(index: number) => void–Called when a move starts toward a different step, or when a drag commits to one.
autoPlaybooleantrueWalk through the steps on its own and loop from the last back to the first. The active dot fills while a step rests. It stops once someone steps, drags, or presses pause, and holds while a mouse hovers the block.
intervalnumber3.2Seconds each step rests before autoplay moves on.
speednumber1Multiplies the pace of every move. At 1 a typical move takes about a second, a little longer when tokens travel across the whole file.
pausedbooleanfalseHolds autoplay where it is. Manual steps still animate.
accentstring–Color of the caret, the changed line bands, and the active step. Defaults to the accent token.
labelstring"Code walkthrough"Accessible name for the walkthrough region.
classNamestring–Extra class on the root.
styleCSSProperties–Inline styles on the root.
  • The root is a labelled section. The code area is a focusable group named with the step position, and its full source for the current step sits in a visually hidden pre, so screen readers read real code rather than the animated layer, which is aria-hidden.
  • Left and right (or up and down) arrows step through the versions, Home and End jump to the first and last. Previous, next, every step dot, and play or pause are real buttons with specific names; the current dot carries aria-current="step".
  • A polite live region announces each step you choose with its title and how many lines it added and removed. Autoplay is not announced, and a pause button stops it.
  • Change is never shown by color alone: the header writes the line counts, the caption names the step, and changed lines carry a hairline mark as well as a tint.
  • Pointer focus draws no ring; keyboard focus shows Arc's shared focus ring. Keyboard position shows through hover fills on the buttons.
  • One rAF loop writes transform, opacity, and clip-path straight to each token, only when a value changed; React renders only when the step changes.
  • Tokens are paired across versions with a longest common subsequence, then leftover words pair by distance, so a line that moved as a whole glides rather than retyping.
  • Positions are written in ch and em, so the moves follow the fitted font size at any width without measuring.
  • Removed words fade and lift first. Kept words glide on the shared in-out curve, a beat later on lower lines. New code types in one character at a time behind an accent caret, which fades once the step is written. The block height and line numbers follow the line count on the same curve.
  • Every move is a pure function of its progress, so it is fully interruptible: dragging sideways scrubs it under the finger and commits past about a third or on a flick, otherwise it rewinds. Stepping back mid move reverses on the same timeline, and a new step mid move starts from where every token is.
  • At either end the text rubber-bands and settles back on a critically damped spring.
  • The loop stops off screen, in hidden tabs, and once a move lands. With reduced motion, autoplay stays off and steps change in one frame, with the changed line bands and counts still shown.
  • The root is a container. The code font fits the widest step to the available width, from 14px down to 10.5px, so lines never wrap and tokens never collide.
  • Below 520px the caption takes its own row and the step controls spread across the width, with 44px tall dots.
  • Dragging is horizontal only, so vertical page scrolling on touch keeps working.
  • About one span per token (under a hundred for the default snippet), each on its own compositor layer, with written values cached.
  • Token pairing runs once per move on small arrays; nothing is measured per frame.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

  • Use it for tutorials, quickstarts, migration guides, and changelog entries where the reader should see how code changes from one version to the next.
  • Keep each step a small, meaningful change and give it a short title. Lines over about 50 characters shrink the font on phones, so wrap long calls.
  • Pass value and onValueChange to sync it with prose beside it, such as a list of steps that highlights as the code moves.

The full library index for assistants is at /llms.txt.