Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply best practices for creating programmatic videos with Remotion and React.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/transitions.md
1---2name: transitions3description: Scene transitions and overlays for Remotion using TransitionSeries.4metadata:5tags: transitions, overlays, fade, slide, wipe, scenes6---78## TransitionSeries910`<TransitionSeries>` arranges scenes and supports two ways to enhance the cut point between them:1112- **Transitions** (`<TransitionSeries.Transition>`) — crossfade, slide, wipe, etc. between two scenes. Shortens the timeline because both scenes play simultaneously during the transition.13- **Overlays** (`<TransitionSeries.Overlay>`) — render an effect (e.g. a light leak) on top of the cut point without shortening the timeline.1415Children are absolutely positioned.1617## Prerequisites1819```bash20npx remotion add @remotion/transitions21```2223## Transition example2425```tsx26import { TransitionSeries, linearTiming } from "@remotion/transitions";27import { fade } from "@remotion/transitions/fade";2829<TransitionSeries>30<TransitionSeries.Sequence durationInFrames={60}>31<SceneA />32</TransitionSeries.Sequence>33<TransitionSeries.Transition34presentation={fade()}35timing={linearTiming({ durationInFrames: 15 })}36/>37<TransitionSeries.Sequence durationInFrames={60}>38<SceneB />39</TransitionSeries.Sequence>40</TransitionSeries>;41```4243## Overlay example4445Any React component can be used as an overlay. For a ready-made effect, see the **light-leaks** rule.4647```tsx48import { TransitionSeries } from "@remotion/transitions";49import { LightLeak } from "@remotion/light-leaks";5051<TransitionSeries>52<TransitionSeries.Sequence durationInFrames={60}>53<SceneA />54</TransitionSeries.Sequence>55<TransitionSeries.Overlay durationInFrames={20}>56<LightLeak />57</TransitionSeries.Overlay>58<TransitionSeries.Sequence durationInFrames={60}>59<SceneB />60</TransitionSeries.Sequence>61</TransitionSeries>;62```6364## Mixing transitions and overlays6566Transitions and overlays can coexist in the same `<TransitionSeries>`, but an overlay cannot be adjacent to a transition or another overlay.6768```tsx69import { TransitionSeries, linearTiming } from "@remotion/transitions";70import { fade } from "@remotion/transitions/fade";71import { LightLeak } from "@remotion/light-leaks";7273<TransitionSeries>74<TransitionSeries.Sequence durationInFrames={60}>75<SceneA />76</TransitionSeries.Sequence>77<TransitionSeries.Overlay durationInFrames={30}>78<LightLeak />79</TransitionSeries.Overlay>80<TransitionSeries.Sequence durationInFrames={60}>81<SceneB />82</TransitionSeries.Sequence>83<TransitionSeries.Transition84presentation={fade()}85timing={linearTiming({ durationInFrames: 15 })}86/>87<TransitionSeries.Sequence durationInFrames={60}>88<SceneC />89</TransitionSeries.Sequence>90</TransitionSeries>;91```9293## Transition props9495`<TransitionSeries.Transition>` requires:9697- `presentation` — the visual effect (e.g. `fade()`, `slide()`, `wipe()`).98- `timing` — controls speed and easing (e.g. `linearTiming()`, `springTiming()`).99100## Overlay props101102`<TransitionSeries.Overlay>` accepts:103104- `durationInFrames` — how long the overlay is visible (positive integer).105- `offset?` — shifts the overlay relative to the cut point center. Positive = later, negative = earlier. Default: `0`.106107## Available transition types108109Import transitions from their respective modules:110111```tsx112import { fade } from "@remotion/transitions/fade";113import { slide } from "@remotion/transitions/slide";114import { wipe } from "@remotion/transitions/wipe";115import { flip } from "@remotion/transitions/flip";116import { clockWipe } from "@remotion/transitions/clock-wipe";117```118119## Slide transition with direction120121```tsx122import { slide } from "@remotion/transitions/slide";123124<TransitionSeries.Transition125presentation={slide({ direction: "from-left" })}126timing={linearTiming({ durationInFrames: 20 })}127/>;128```129130Directions: `"from-left"`, `"from-right"`, `"from-top"`, `"from-bottom"`131132## Timing options133134```tsx135import { linearTiming, springTiming } from "@remotion/transitions";136137// Linear timing - constant speed138linearTiming({ durationInFrames: 20 });139140// Spring timing - organic motion141springTiming({ config: { damping: 200 }, durationInFrames: 25 });142```143144## Duration calculation145146Transitions overlap adjacent scenes, so the total composition length is **shorter** than the sum of all sequence durations. Overlays do **not** affect the total duration.147148For example, with two 60-frame sequences and a 15-frame transition:149150- Without transitions: `60 + 60 = 120` frames151- With transition: `60 + 60 - 15 = 105` frames152153Adding an overlay between two other sequences does not change the total.154155### Getting the duration of a transition156157Use the `getDurationInFrames()` method on the timing object:158159```tsx160import { linearTiming, springTiming } from "@remotion/transitions";161162const linearDuration = linearTiming({163durationInFrames: 20,164}).getDurationInFrames({ fps: 30 });165// Returns 20166167const springDuration = springTiming({168config: { damping: 200 },169}).getDurationInFrames({ fps: 30 });170// Returns calculated duration based on spring physics171```172173For `springTiming` without an explicit `durationInFrames`, the duration depends on `fps` because it calculates when the spring animation settles.174175### Calculating total composition duration176177```tsx178import { linearTiming } from "@remotion/transitions";179180const scene1Duration = 60;181const scene2Duration = 60;182const scene3Duration = 60;183184const timing1 = linearTiming({ durationInFrames: 15 });185const timing2 = linearTiming({ durationInFrames: 20 });186187const transition1Duration = timing1.getDurationInFrames({ fps: 30 });188const transition2Duration = timing2.getDurationInFrames({ fps: 30 });189190const totalDuration =191scene1Duration +192scene2Duration +193scene3Duration -194transition1Duration -195transition2Duration;196// 60 + 60 + 60 - 15 - 20 = 145 frames197```198