Before After
A divider sweeps across a framed image to reveal the after version, then settles back to the pause point. A free, MIT-licensed Remotion media layout.
$ pnpm dlx shadcn@latest add @remocn/before-afterUsage
// src/Root.tsx
import { Composition } from "remotion";
import { BeforeAfter } from "@/components/remocn/before-after";
const BeforeAfterScene = () => (
<BeforeAfter
before="/shots/raw.jpg"
after="/shots/graded.jpg"
title="Graded in one pass"
/>
);
export const RemotionRoot = () => (
<Composition
id="BeforeAfter"
component={BeforeAfterScene}
durationInFrames={150}
fps={30}
width={1280}
height={720}
/>
);A framed image appears with a grip handle. The divider sweeps across to reveal the after version, then returns to pauseAt before the grip fades. Pass your own before and after image URLs, with optional labels and a title. If neither is given, the built-in demo image shows a flat look against a graded look and uses a staticFile from the Remocn repo. It ships light and dark through theme.
The ground is a live gradients.sh shader (GshGround), installed with the component as @remocn/gsh. Pick another look with the ground preset prop.
Props20
| Prop | Type | Default |
|---|---|---|
| before | string— Image URL for the before side. Defaults to a repo-only file. | |
| after | string— Image URL for the after side. Defaults to a repo-only file. | |
| beforeLabel | string"Before" Label on the before side. | |
| afterLabel | string"After" Label on the after side. | |
| title | string— Optional title above the frame. | |
| aspect | number— Aspect ratio of the frame. Defaults to 16:9, or 4:5 in portrait. | |
| fit | "cover" | "contain""cover" How images fill the frame. | |
| pauseAt | number0.5 Divider position where the sweep rests, 0 to 1. | |
| hold | number54 Frames the divider rests at pauseAt before sweeping to the after side. | |
| radius | number16 Corner radius of the frame, in px at 1280 wide. | |
| accent | string"#3B5BFD" Accent color of the grip and divider. | |
| ink | string— Text color; overrides the theme ink. | |
| background | string— Solid background color for the stage. | |
| fontFamily | string"Hanken Grotesk" Typeface for the copy. Load the font in your project first. | |
| ground | GshPresetId— Shader preset id for the animated background. | |
| groundParams | Partial<GradientParams>— Partial shader parameters that override the ground preset. | |
| scale | number1 Size of the foreground around the frame's center; the background stays put. | |
| delay | number0 Frames to hold the first frame before anything moves. | |
| speed | number1 Playback speed multiplier for the whole timeline. | |
| theme | "dark" | "light""dark" Color scheme. Ships light and dark. | |
- beforestring
Image URL for the before side. Defaults to a repo-only file.
- afterstring
Image URL for the after side. Defaults to a repo-only file.
- beforeLabelstring
Label on the before side.
Default
"Before" - afterLabelstring
Label on the after side.
Default
"After" - titlestring
Optional title above the frame.
- aspectnumber
Aspect ratio of the frame. Defaults to 16:9, or 4:5 in portrait.
- fit"cover" | "contain"
How images fill the frame.
Default
"cover" - pauseAtnumber
Divider position where the sweep rests, 0 to 1.
Default
0.5 - holdnumber
Frames the divider rests at pauseAt before sweeping to the after side.
Default
54 - radiusnumber
Corner radius of the frame, in px at 1280 wide.
Default
16 - accentstring
Accent color of the grip and divider.
Default
"#3B5BFD" - inkstring
Text color; overrides the theme ink.
- backgroundstring
Solid background color for the stage.
- fontFamilystring
Typeface for the copy. Load the font in your project first.
Default
"Hanken Grotesk" - groundGshPresetId
Shader preset id for the animated background.
- groundParamsPartial<GradientParams>
Partial shader parameters that override the ground preset.
- scalenumber
Size of the foreground around the frame's center; the background stays put.
Default
1 - delaynumber
Frames to hold the first frame before anything moves.
Default
0 - speednumber
Playback speed multiplier for the whole timeline.
Default
1 - theme"dark" | "light"
Color scheme. Ships light and dark.
Default
"dark"