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/sequencing.md
1---2name: sequencing3description: Sequencing patterns for Remotion - delay, trim, limit duration of items4metadata:5tags: sequence, series, timing, delay, trim6---78Use `<Sequence>` to delay when an element appears in the timeline.910```tsx11import { Sequence } from "remotion";1213export const Title = () => {14const frame = useCurrentFrame();15const { fps } = useVideoConfig();1617const opacity = interpolate(frame, [0, 2 * fps], [0, 1], {18extrapolateRight: "clamp",19extrapolateLeft: "clamp",20easing: Easing.bezier(0.16, 1, 0.3, 1),21});2223return <div style={{ opacity }}>Title</div>;24};2526export const Subtitle = () => {27return <div>Subtitle</div>;28};2930const Main = () => {31const {fps} = useVideoConfig();3233return (34<AbsoluteFill>35<Sequence>36<Background />37</Sequence>38<Sequence from={1 * fps} durationInFrames={2 * fps} layout="none">39<Title />40</Sequence>41<Sequence from={2 * fps} durationInFrames={2 * fps} layout="none">42<Subtitle />43</Sequence>44</AbsoluteFill>45);46}47```4849This will by default wrap the component in an absolute fill element.50If the items should not be wrapped, use the `layout` prop:5152```tsx53<Sequence layout="none">54<Title />55</Sequence>56```5758## Premounting5960This loads the component in the timeline before it is actually played.61Always premount any `<Sequence>`!6263```tsx64<Sequence premountFor={1 * fps}>65<Title />66</Sequence>67```6869## Series7071Use `<Series>` when elements should play one after another without overlap.7273```tsx74import { Series } from "remotion";7576<Series>77<Series.Sequence durationInFrames={45}>78<Intro />79</Series.Sequence>80<Series.Sequence durationInFrames={60}>81<MainContent />82</Series.Sequence>83<Series.Sequence durationInFrames={30}>84<Outro />85</Series.Sequence>86</Series>;87```8889Same as with `<Sequence>`, the items will be wrapped in an absolute fill element by default when using `<Series.Sequence>`, unless the `layout` prop is set to `none`.9091### Series with overlaps9293Use negative offset for overlapping sequences:9495```tsx96<Series>97<Series.Sequence durationInFrames={60}>98<SceneA />99</Series.Sequence>100<Series.Sequence offset={-15} durationInFrames={60}>101{/* Starts 15 frames before SceneA ends */}102<SceneB />103</Series.Sequence>104</Series>105```106107## Frame References Inside Sequences108109Inside a Sequence, `useCurrentFrame()` returns the local frame (starting from 0):110111```tsx112<Sequence from={60} durationInFrames={30}>113<MyComponent />114{/* Inside MyComponent, useCurrentFrame() returns 0-29, not 60-89 */}115</Sequence>116```117118## Nested Sequences119120Sequences can be nested for complex timing:121122```tsx123<Sequence from={0} durationInFrames={120}>124<Background />125<Sequence from={15} durationInFrames={90} layout="none">126<Title />127</Sequence>128<Sequence from={45} durationInFrames={60} layout="none">129<Subtitle />130</Sequence>131</Sequence>132```133134## Nesting compositions within another135136To add a composition within another composition, you can use the `<Sequence>` component with a `width` and `height` prop to specify the size of the composition.137138```tsx139<AbsoluteFill>140<Sequence width={COMPOSITION_WIDTH} height={COMPOSITION_HEIGHT}>141<CompositionComponent />142</Sequence>143</AbsoluteFill>144```145