When to Use the Null Component in Remotion
The Null component is a specialized "no-op" element that renders nothing and contributes zero duration to your Remotion compositions. Understanding when to use the Null component in Remotion helps you manage conditional rendering, branching timelines, and development workflows without breaking your video's timing or layout.
Common Use Cases for the Null Component
| Situation | Why Null Helps |
Recommended Pattern |
|---|---|---|
| Conditional rendering of a component that should disappear completely for part of the timeline | Null removes the element from the render tree so it does not occupy any space or affect layout |
tsx<br/>{showBanner ? <Banner /> : <Null />}<br/> |
| Branching timelines where two alternative sub-trees share the same parent but only one should be active at any time | Using Null for the inactive branch guarantees the branch contributes no frames to the final video, keeping the parent's duration correct |
tsx<br/><Sequence durationInFrames={isIntro ? 150 : 0}><br/> {isIntro ? <Intro /> : <Null />}<br/></Sequence><br/> |
| Placeholder for future content while prototyping | You can commit a Null placeholder without breaking the layout or animation timing |
tsx<br/>// TODO: replace with real component later<br/>export const UpcomingFeature = () => <Null />;<br/> |
| Breaking a component tree deliberately for testing or debugging | Inserting Null isolates a subtree, allowing you to verify that other parts render correctly |
tsx<br/><Group><br/> <Null /><br/> <OtherStuff /><br/></Group><br/> |
| Avoiding React warnings when a component expects a child but you have nothing to render | Null satisfies the type-check while rendering nothing |
tsx<br/><OptionalWrapper>{hasContent ? <Content /> : <Null />}</OptionalWrapper><br/> |
How the Null Component Works Internally
The Null component is defined in src/renderer/components/Null.tsx and simply returns null. Because Remotion treats the component as a regular React element, its duration is inferred from its children. Since it has no children, its duration defaults to 0 frames. The component does not allocate any GPU resources, making it cheap to keep in the tree even when unused.
Source: Null component implementation
Code Examples
Conditional Rendering Inside a Sequence
import {Sequence, Null, AbsoluteFill, Video} from 'remotion';
export const MyVideo = ({showIntro}: {showIntro: boolean}) => {
return (
<>
{/* Intro plays only when showIntro is true */}
<Sequence durationInFrames={showIntro ? 150 : 0}>
{showIntro ? <Intro /> : <Null />}
</Sequence>
{/* Main content always plays */}
<AbsoluteFill>
<Video src="myClip.mp4" />
</AbsoluteFill>
</>
);
};
Branching Timelines with Mutually Exclusive Scenes
import {Sequence, Null, Video} from 'remotion';
export const BranchingDemo = ({branch}: {branch: 'A' | 'B'}) => (
<>
{/* Branch A */}
<Sequence durationInFrames={branch === 'A' ? 200 : 0}>
{branch === 'A' ? <SceneA /> : <Null />}
</Sequence>
{/* Branch B */}
<Sequence durationInFrames={branch === 'B' ? 200 : 0}>
{branch === 'B' ? <SceneB /> : <Null />}
</Sequence>
</>
);
Placeholder During Development
import {Null} from 'remotion';
export const UpcomingFeature = () => {
// TODO: replace with real component later
return <Null />;
};
Key Implementation Files
| File | Role | Link |
|---|---|---|
src/renderer/components/Null.tsx |
Minimal component that returns null; the heart of the feature |
https://github.com/remotion-dev/remotion/blob/main/src/renderer/components/Null.tsx |
src/renderer/components/Sequence.tsx |
Demonstrates how durationInFrames interacts with child components (including Null) |
https://github.com/remotion-dev/remotion/blob/main/src/renderer/components/Sequence.tsx |
src/docs/advanced/conditional-rendering.md |
Documentation that mentions using Null for conditional branches |
https://github.com/remotion-dev/remotion/blob/main/docs/advanced/conditional-rendering.md |
Summary
Knowing when to use the Null component in Remotion streamlines your workflow for conditional video rendering, timeline branching, and prototyping. By returning zero frames and occupying no layout space, Null serves as the ideal placeholder for inactive branches without affecting your composition's timing or performance.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →