Opus Motion ★ Star on GitHub

UI · code-diff-highlight

Code diff highlight

A code-review window with a file-name header: removed lines in red and added lines in green sweep in one by one with old/new line-number gutters, a +/- column and light syntax colouring, then a +N/−M badge pops and unchanged context dims.

A free, MIT-licensed UI animation from the Opus Motion Library — 616 motions for Remotion, React and plain HTML.

Code diff highlight: three frames of the UI animation, start, middle and end
Code diff highlight — start, middle and end of the 7.0-second motion.

What Code diff highlight is for

Pull-request and code-review explainers, "what changed" beats, refactor / bug-fix walkthroughs, changelog and developer-tool promos, AI-coding demos.

  • diff
  • code
  • git
  • pull request
  • review
  • developer
  • changelog
  • refactor
  • software
  • programming
  • commit
  • patch
  • ui
  • overlay

Details

Category
UI & product mockup animations
Length
7.0 s (210 frames at 30 fps)
Formats
16:9, 1:1, 9:16
Weight
light
Transparent overlay
yes
Seamless loop
no
Text props
lines caption
Colour props
background panel ink addColor delColor accent
Mood
ui
Roles
accent, subject

Use Code diff highlight in Remotion, React or HTML

Remotion project

terminal
# copy this motion into your Remotion project
node cli/mgl.mjs add code-diff-highlight --to ../my-app/src

# render an mp4 (run in the library folder)
node cli/mgl.mjs render code-diff-highlight --props '{"lines":[{"type":"ctx","text":"export function isValid(session: Session) {"},{"type":"del","text":"  return session.token !== null;"},{"type":"add","text":"  if (!session.token) return false;"},{"type":"add","text":"  const expired = Date.now() > session.expiresAt;"},{"type":"add","text":"  return !expired;"},{"type":"ctx","text":"}"},{"type":"ctx","text":""},{"type":"del","text":"const TTL = 60 * 60;"},{"type":"add","text":"const TTL = 15 * 60; // shorter sessions"}],"caption":"Reject expired sessions","background":"#0B0E14","panel":"#12161F","ink":"#E6EAF2","addColor":"#2EA043","delColor":"#F85149","accent":"#79B8FF"}'

# or export for apps / editors: mp4 | webm-alpha | prores-alpha | gif | png | poster
node cli/mgl.mjs export code-diff-highlight --as webm-alpha --props '{"lines":[{"type":"ctx","text":"export function isValid(session: Session) {"},{"type":"del","text":"  return session.token !== null;"},{"type":"add","text":"  if (!session.token) return false;"},{"type":"add","text":"  const expired = Date.now() > session.expiresAt;"},{"type":"add","text":"  return !expired;"},{"type":"ctx","text":"}"},{"type":"ctx","text":""},{"type":"del","text":"const TTL = 60 * 60;"},{"type":"add","text":"const TTL = 15 * 60; // shorter sessions"}],"caption":"Reject expired sessions","background":"#0B0E14","panel":"#12161F","ink":"#E6EAF2","addColor":"#2EA043","delColor":"#F85149","accent":"#79B8FF"}'

React / Next.js

tsx
import {MotionPlayer} from 'opus-motion-library/web';

<MotionPlayer
  motion="code-diff-highlight"
  props={{
    lines: [
      {type: 'ctx', text: 'export function isValid(session: Session) {'},
      {type: 'del', text: '  return session.token !== null;'},
      {type: 'add', text: '  if (!session.token) return false;'},
      {
        type: 'add',
        text: '  const expired = Date.now() > session.expiresAt;',
      },
      {type: 'add', text: '  return !expired;'},
      {type: 'ctx', text: '}'},
      {type: 'ctx', text: ''},
      {type: 'del', text: 'const TTL = 60 * 60;'},
      {type: 'add', text: 'const TTL = 15 * 60; // shorter sessions'},
    ],
    caption: 'Reject expired sessions',
    background: '#0B0E14',
    panel: '#12161F',
    ink: '#E6EAF2',
    addColor: '#2EA043',
    delColor: '#F85149',
    accent: '#79B8FF',
  }}
  playOnView
  loop="auto"
/>

Plain HTML / WordPress

html
<script src="opus-motion.element.js" defer></script>

<opus-motion motion="code-diff-highlight"
  props='{"lines":[{"type":"ctx","text":"export function isValid(session: Session) {"},{"type":"del","text":"  return session.token !== null;"},{"type":"add","text":"  if (!session.token) return false;"},{"type":"add","text":"  const expired = Date.now() > session.expiresAt;"},{"type":"add","text":"  return !expired;"},{"type":"ctx","text":"}"},{"type":"ctx","text":""},{"type":"del","text":"const TTL = 60 * 60;"},{"type":"add","text":"const TTL = 15 * 60; // shorter sessions"}],"caption":"Reject expired sessions","background":"#0B0E14","panel":"#12161F","ink":"#E6EAF2","addColor":"#2EA043","delColor":"#F85149","accent":"#79B8FF"}'>
</opus-motion>

Compose spec (multi-scene video)

json
{
  "width": 1920,
  "height": 1080,
  "fps": 30,
  "scenes": [
    {
      "motion": "code-diff-highlight",
      "props": {
        "lines": [
          {
            "type": "ctx",
            "text": "export function isValid(session: Session) {"
          },
          {
            "type": "del",
            "text": "  return session.token !== null;"
          },
          {
            "type": "add",
            "text": "  if (!session.token) return false;"
          },
          {
            "type": "add",
            "text": "  const expired = Date.now() > session.expiresAt;"
          },
          {
            "type": "add",
            "text": "  return !expired;"
          },
          {
            "type": "ctx",
            "text": "}"
          },
          {
            "type": "ctx",
            "text": ""
          },
          {
            "type": "del",
            "text": "const TTL = 60 * 60;"
          },
          {
            "type": "add",
            "text": "const TTL = 15 * 60; // shorter sessions"
          }
        ],
        "caption": "Reject expired sessions",
        "background": "#0B0E14",
        "panel": "#12161F",
        "ink": "#E6EAF2",
        "addColor": "#2EA043",
        "delColor": "#F85149",
        "accent": "#79B8FF"
      }
    }
  ]
}

Code diff highlight props

15 parameters — change any of them to make the motion yours.

PropDefaultWhat it does
fileName"src/auth/session.ts"file path shown in the window header
hunkHeader""hunk line above the code, e.g. '@@ -12,7 +12,9 @@' (empty = computed from the lines)
lines[{"type":"ctx","text":"export function isValid(session: Session) {"},{"type":"del","tex…diff lines [{type: 'add' | 'del' | 'ctx', text}] — text is plain code, no +/- prefix
startLine12first line number in the gutters
caption"Reject expired sessions"one-line takeaway under the window (empty = none)
every9frames between lines
speed1timing multiplier
startAt0frame the window starts
background"#0B0E14"page colour or 'transparent'
panel"#12161F"window colour (dark or light — syntax colours adapt)
ink"#E6EAF2"text colour
addColor"#2EA043"added-line colour
delColor"#F85149"removed-line colour
accent"#79B8FF"hunk-header colour
fontFamily""monospace font override (empty = JetBrains Mono)

Notes & credits

Technique sources:

  • original (generic developer explainer)