Skip to content

πŸŽ₯ Make videos programmatically with React

Docs: Rename Examples to Remotion Elements (#8617)

Igor Samokhovets3e2fb9378f07
diff --git a/packages/docs/docusaurus.config.ts b/packages/docs/docusaurus.config.ts
index 658739b48e..eb2dd9a2b7 100644
--- a/packages/docs/docusaurus.config.ts
+++ b/packages/docs/docusaurus.config.ts
@@ -326,10 +326,10 @@ const config: Config = {
[
'@docusaurus/plugin-content-docs',
{
- id: 'examples',
- path: './examples',
- routeBasePath: 'examples',
- sidebarPath: './examples-sidebars.ts',
+ id: 'elements',
+ path: './elements',
+ routeBasePath: 'elements',
+ sidebarPath: './elements-sidebars.ts',
editUrl:
'https://github.com/remotion-dev/remotion/edit/main/packages/docs/',
showLastUpdateTime: showGitLastUpdate,
diff --git a/packages/docs/examples-sidebars.ts b/packages/docs/elements-sidebars.ts
similarity index 65%
rename from packages/docs/examples-sidebars.ts
rename to packages/docs/elements-sidebars.ts
index 2461dbc0e1..3836504c5b 100644
--- a/packages/docs/examples-sidebars.ts
+++ b/packages/docs/elements-sidebars.ts
@@ -2,9 +2,9 @@
import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
const sidebars: SidebarsConfig = {
- examplesSidebar: [
+ elementsSidebar: [
'index',
- 'submit-an-example',
+ 'submit-an-element',
{
type: 'html',
value:
@@ -13,10 +13,10 @@ const sidebars: SidebarsConfig = {
},
{
type: 'category',
- label: 'Motion design system',
- link: {type: 'doc', id: 'motion-design-system/index'},
+ label: 'Overlays',
+ link: {type: 'doc', id: 'overlays/index'},
collapsed: false,
- items: ['motion-design-system/lower-third/index'],
+ items: ['overlays/lower-third/index'],
},
],
};
diff --git a/packages/docs/examples-template/example.tsx b/packages/docs/elements-template/element.tsx
similarity index 85%
rename from packages/docs/examples-template/example.tsx
rename to packages/docs/elements-template/element.tsx
index 00754cad15..aeb47821c9 100644
--- a/packages/docs/examples-template/example.tsx
+++ b/packages/docs/elements-template/element.tsx
@@ -6,7 +6,7 @@ export const height = 1080;
export const fps = 30;
export const durationInFrames = 120;
-export const ExampleComponent: React.FC = () => {
+export const ElementComponent: React.FC = () => {
return (
<AbsoluteFill
style={{
@@ -20,7 +20,7 @@ export const ExampleComponent: React.FC = () => {
justifyContent: 'center',
}}
>
- Example
+ Element
</AbsoluteFill>
);
};
@@ -28,8 +28,8 @@ export const ExampleComponent: React.FC = () => {
export const RemotionRoot: React.FC = () => {
return (
<Composition
- id="Example"
- component={ExampleComponent}
+ id="Element"
+ component={ElementComponent}
durationInFrames={durationInFrames}
fps={fps}
height={height}
diff --git a/packages/docs/examples-template/index.mdx b/packages/docs/elements-template/index.mdx
similarity index 63%
rename from packages/docs/examples-template/index.mdx
rename to packages/docs/elements-template/index.mdx
index 623fb38b66..6a071c9fec 100644
--- a/packages/docs/examples-template/index.mdx
+++ b/packages/docs/elements-template/index.mdx
@@ -1,30 +1,30 @@
---
-title: Example title
-description: One sentence describing what this example shows.
+title: Element title
+description: One sentence describing what this element shows.
---
-import {ExamplePage} from '@site/src/components/Examples/ExamplePage';
+import {ElementPage} from '@site/src/components/Elements/ElementPage';
import {
- ExampleComponent,
+ ElementComponent,
durationInFrames,
fps,
height,
width,
-} from './example';
+} from './element';
-# Example title
+# Element title
-One short paragraph explaining what this example demonstrates and when to use it.
+One short paragraph explaining what this element demonstrates and when to use it.
-<ExamplePage
- component={ExampleComponent}
+<ElementPage
+ component={ElementComponent}
durationInFrames={durationInFrames}
fps={fps}
height={height}
width={width}
>
-```tsx twoslash title="example.tsx"
+```tsx twoslash title="element.tsx"
import React from 'react';
import {AbsoluteFill, Composition} from 'remotion';
@@ -33,7 +33,7 @@ export const height = 1080;
export const fps = 30;
export const durationInFrames = 120;
-export const ExampleComponent: React.FC = () => {
+export const ElementComponent: React.FC = () => {
return (
<AbsoluteFill
style={{
@@ -47,7 +47,7 @@ export const ExampleComponent: React.FC = () => {
justifyContent: 'center',
}}
>
- Example
+ Element
</AbsoluteFill>
);
};
@@ -55,8 +55,8 @@ export const ExampleComponent: React.FC = () => {
export const RemotionRoot: React.FC = () => {
return (
<Composition
- id="Example"
- component={ExampleComponent}
+ id="Element"
+ component={ElementComponent}
durationInFrames={durationInFrames}
fps={fps}
height={height}
@@ -66,4 +66,4 @@ export const RemotionRoot: React.FC = () => {
};
```
-</ExamplePage>
+</ElementPage>
diff --git a/packages/docs/elements/index.mdx b/packages/docs/elements/index.mdx
new file mode 100644
index 0000000000..0e70890e39
--- /dev/null
+++ b/packages/docs/elements/index.mdx
@@ -0,0 +1,39 @@
+---
+title: Remotion Elements
+sidebar_label: Overview
+description: Drop-in, remixable video building blocks for Remotion.
+---
+
+# Remotion Elements
+
+:::warning Work in progress
+
+This section is being shaped. The format and Element list may change.
+
+:::
+
+Remotion Elements are drop-in, HTML-first Remotion components designed to be placed inside a [`<Sequence>`](/docs/sequence) and composed with your video.
+
+They are practical video building blocks: captions, lower thirds, overlays, callouts, transitions, data cards, audio visuals, and title cards.
+
+## Methodology
+
+An Element should be:
+
+- Small, focused, and useful in real videos
+- Designed to live inside one `<Sequence>`
+- Remixable source code that users can edit, not a black-box dependency
+- HTML, CSS, and React-first for the first version
+- Zero-dependency where possible, with Remotion Effects as an exception
+- Safe to compose in Studio with normal z-layering
+- Free of unexpected global styles, layout side effects, and fullscreen assumptions unless it is explicitly a background
+
+Heavier Maps, Three.js, WebGL, Canvas, and R3F Elements can come later as separate batches of work.
+
+## What belongs here?
+
+Elements should focus on one visual idea, technique, or workflow. They should be actionable Remotion building blocks rather than full, highly specific video templates.
+
+Initial categories include Text, Captions, Overlays, Transitions, Backgrounds, Data, and Audio.
+
+If you want to contribute one, see [Submit an Element](/elements/submit-an-element).
diff --git a/packages/docs/elements/overlays/index.mdx b/packages/docs/elements/overlays/index.mdx
new file mode 100644
index 0000000000..fb40d9ec84
--- /dev/null
+++ b/packages/docs/elements/overlays/index.mdx
@@ -0,0 +1,10 @@
+---
+title: Overlays
+description: Drop-in overlay Elements for Remotion videos.
+---
+
+# Overlays
+
+Elements:
+
+- [Lower third](/elements/overlays/lower-third/)
diff --git a/packages/docs/examples/motion-design-system/lower-third/index.mdx b/packages/docs/elements/overlays/lower-third/index.mdx
similarity index 93%
rename from packages/docs/examples/motion-design-system/lower-third/index.mdx
rename to packages/docs/elements/overlays/lower-third/index.mdx
index 26f493b306..5bcf3836e8 100644
--- a/packages/docs/examples/motion-design-system/lower-third/index.mdx
+++ b/packages/docs/elements/overlays/lower-third/index.mdx
@@ -3,7 +3,7 @@ title: Lower third
description: Create a reusable lower-third title animation.
---
-import {ExamplePage} from '@site/src/components/Examples/ExamplePage';
+import {ElementPage} from '@site/src/components/Elements/ElementPage';
import {
LowerThird,
durationInFrames,
@@ -16,7 +16,7 @@ import {
Create a reusable lower-third title animation.
-<ExamplePage
+<ElementPage
component={LowerThird}
durationInFrames={durationInFrames}
fps={fps}
@@ -63,8 +63,8 @@ export const LowerThird: React.FC = () => {
return (
<AbsoluteFill
style={{
- background: 'linear-gradient(135deg, #0b1020, #15234a)',
fontFamily: 'Inter, system-ui, sans-serif',
+ pointerEvents: 'none',
}}
>
<div
@@ -134,4 +134,4 @@ export const RemotionRoot: React.FC = () => {
};
```
-</ExamplePage>
+</ElementPage>
diff --git a/packages/docs/examples/motion-design-system/lower-third/lower-third.tsx b/packages/docs/elements/overlays/lower-third/lower-third.tsx
similarity index 96%
rename from packages/docs/examples/motion-design-system/lower-third/lower-third.tsx
rename to packages/docs/elements/overlays/lower-third/lower-third.tsx
index 7943abfd15..51c8c9eafb 100644
--- a/packages/docs/examples/motion-design-system/lower-third/lower-third.tsx
+++ b/packages/docs/elements/overlays/lower-third/lower-third.tsx
@@ -36,8 +36,8 @@ export const LowerThird: React.FC = () => {
return (
<AbsoluteFill
style={{
- background: 'linear-gradient(135deg, #0b1020, #15234a)',
fontFamily: 'Inter, system-ui, sans-serif',
+ pointerEvents: 'none',
}}
>
<div
diff --git a/packages/docs/examples/submit-an-example.mdx b/packages/docs/elements/submit-an-element.mdx
similarity index 52%
rename from packages/docs/examples/submit-an-example.mdx
rename to packages/docs/elements/submit-an-element.mdx
index 116cb4438c..a7543ff539 100644
--- a/packages/docs/examples/submit-an-example.mdx
+++ b/packages/docs/elements/submit-an-element.mdx
@@ -1,39 +1,41 @@
---
-title: Submit an example
-description: Submit a Remotion example for the examples gallery.
+title: Submit an Element
+description: Submit a Remotion Element for the Elements gallery.
---
-# Submit an example
+# Submit an Element
-Have a small, remixable Remotion example? We'd love to see it.
+Have a small, remixable Remotion Element? We'd like to see it.
-Examples should be submitted with code. A strong submission is easy to preview, easy to copy into a Remotion project, and useful as a building block in real videos.
+A strong Element is easy to preview, easy to copy into a Remotion project, and useful as a building block inside a [`<Sequence>`](/docs/sequence).
-## Preferred example format
+## Preferred Element format
-An example should ideally be a single, self-contained TSX file.
+An Element should ideally be a single, self-contained TSX file.
-Each example should live in its own folder: `packages/docs/examples/<category>/<slug>/`.
-Put the MDX page at `packages/docs/examples/<category>/<slug>/index.mdx` and the TSX source next to it.
+Each Element should live in its own folder: `packages/docs/elements/<category>/<slug>/`.
+Put the MDX page at `packages/docs/elements/<category>/<slug>/index.mdx` and the TSX source next to it.
-Start from the reusable template in `packages/docs/examples-template/`.
+Start from the reusable template in `packages/docs/elements-template/`.
-The MDX page imports that TSX file for the live preview, and shows the exact same code in a fenced `tsx` code block. Keeping the displayed code inline (rather than generating it at build time) means both readers in the browser and AI agents reading the served Markdown see the full source. A test (`src/test/examples.test.ts`) enforces that the code block stays identical to the source file.
+The MDX page imports that TSX file for the live preview, and shows the exact same code in a fenced `tsx` code block. Keeping the displayed code inline means both readers in the browser and AI agents reading the served Markdown see the full source. A test (`src/test/elements.test.ts`) enforces that the code block stays identical to the source file.
The preferred format is:
-- Export the example component
+- Export the Element component
- Export fixed `width`, `height`, `fps`, and `durationInFrames`
- Define the Remotion [`<Composition>`](/docs/composition) directly in the file
- No local imports, except from npm packages
-- No multiple files required to understand or use the example
+- No multiple files required to understand or use the Element
- Copy-pastable into a Remotion project
+- HTML, CSS, and React-first
+- Zero-dependency where possible
- Binary assets use remote URLs only
- Remote assets are publicly accessible and stable
For example:
-```tsx twoslash title="Example.tsx"
+```tsx twoslash title="Element.tsx"
import {Composition} from 'remotion';
export const width = 1920;
@@ -41,15 +43,15 @@ export const height = 1080;
export const fps = 30;
export const durationInFrames = 120;
-export const MyExample = () => {
+export const MyElement = () => {
return <div>...</div>;
};
export const RemotionRoot = () => {
return (
<Composition
- id="MyExample"
- component={MyExample}
+ id="MyElement"
+ component={MyElement}
width={width}
height={height}
fps={fps}
@@ -62,56 +64,57 @@ export const RemotionRoot = () => {
The MDX page can then use the shared page template, which renders a preview, a "Use it" section, and the source code:
````mdx title="index.mdx"
-import {ExamplePage} from '@site/src/components/Examples/ExamplePage';
+import {ElementPage} from '@site/src/components/Elements/ElementPage';
import {
- MyExample,
+ MyElement,
durationInFrames,
fps,
height,
width,
-} from './my-example';
+} from './my-element';
-<ExamplePage
- component={MyExample}
+<ElementPage
+ component={MyElement}
durationInFrames={durationInFrames}
fps={fps}
height={height}
width={width}
>
-```tsx twoslash title="my-example.tsx"
-// Paste the full contents of my-example.tsx here.
+```tsx twoslash title="my-element.tsx"
+// Paste the full contents of my-element.tsx here.
// It must match the file exactly β€” a test enforces this.
```
-</ExamplePage>
+</ElementPage>
````
The fenced code block must be an exact copy of the colocated TSX file. This is intentional: it keeps the source visible in the served Markdown for agents while the imported module powers the live preview.
-If an example needs binary assets, they should be referenced by URL:
+If an Element needs binary assets, reference them by URL:
```tsx twoslash title="Remote assets"
-const imageUrl = 'https://remotion.media/example-image.png';
-const videoUrl = 'https://remotion.media/example-video.mp4';
+const imageUrl = 'https://remotion.media/element-image.png';
+const videoUrl = 'https://remotion.media/element-video.mp4';
```
-## What makes a good example?
+## What makes a good Element?
-A good example is:
+A good Element is:
- Small enough to understand quickly
- Useful in more than one project
- Easy to remix
- Focused on one visual idea, technique, or workflow
+- Designed to be placed inside a `<Sequence>`
- Possible to preview with a short rendered video or still image
- Actionable for a Remotion user
## What to include
-When submitting an example as a pull request, include:
+When submitting an Element as a pull request, include:
-- An example folder in `packages/docs/examples/<category>/<slug>/`
+- An Element folder in `packages/docs/elements/<category>/<slug>/`
- An `index.mdx` page and the single-file TSX source code in that folder
- What the viewer should see
- A rendered preview, if available
@@ -125,12 +128,14 @@ These are usually less suitable:
- Full video templates with many unrelated parts
- Highly specific branded videos
-- Examples requiring private APIs or private assets
+- Elements requiring private APIs or private assets
- Large apps with many moving parts
-- Examples that cannot be previewed meaningfully
+- Maps, Three.js, WebGL, Canvas, or R3F-heavy Elements for the first batch
+- Elements with unexpected global styles or layout side effects
+- Elements that cannot be previewed meaningfully
-## Submit your example
+## Submit your Element
-Submit examples by opening a pull request against the Remotion repository.
+Submit Elements by opening a pull request against the Remotion repository.
[Open a pull request on GitHub](https://github.com/remotion-dev/remotion/compare)
diff --git a/packages/docs/examples/index.mdx b/packages/docs/examples/index.mdx
deleted file mode 100644
index f835527ca8..0000000000
--- a/packages/docs/examples/index.mdx
+++ /dev/null
@@ -1,25 +0,0 @@
----
-title: Examples
-sidebar_label: Overview
-description: Small, remixable motion graphics examples for Remotion.
----
-
-# Examples
-
-:::warning Work in progress
-
-This section is being shaped. The format and example list may change.
-
-:::
-
-This section will collect small, remixable motion graphics examples for Remotion.
-
-The goal is to make examples that are easy to understand, easy to adapt, and useful as building blocks in real projects.
-
-## What belongs here?
-
-Examples should be focused on one visual idea, technique, or workflow. They should be actionable for Remotion users rather than full, highly specific video templates.
-
-The final example format is still being defined. A good format should work both for previewing the result and for helping users quickly use the example in their own project.
-
-If you want to contribute one, see [Submit an example](/examples/submit-an-example).
diff --git a/packages/docs/examples/motion-design-system/index.mdx b/packages/docs/examples/motion-design-system/index.mdx
deleted file mode 100644
index 1a0d32d156..0000000000
--- a/packages/docs/examples/motion-design-system/index.mdx
+++ /dev/null
@@ -1,10 +0,0 @@
----
-title: Motion design system
-description: Reusable motion design system examples for Remotion.
----
-
-# Motion design system
-
-Examples:
-
-- [Lower third](/examples/motion-design-system/lower-third/)
diff --git a/packages/docs/prewarm-twoslash.ts b/packages/docs/prewarm-twoslash.ts
index 4af8e7908c..56bbc3c969 100644
--- a/packages/docs/prewarm-twoslash.ts
+++ b/packages/docs/prewarm-twoslash.ts
@@ -278,7 +278,7 @@ async function main() {
const startTime = performance.now();
const glob = new Glob('**/*.{mdx,md}');
- const dirs = ['docs', 'blog', 'learn', 'new-docs', 'examples'];
+ const dirs = ['docs', 'blog', 'learn', 'new-docs', 'elements'];
const allFiles: string[] = [];
for (const dir of dirs) {
diff --git a/packages/docs/src/components/Examples/ExamplePage.tsx b/packages/docs/src/components/Elements/ElementPage.tsx
similarity index 83%
rename from packages/docs/src/components/Examples/ExamplePage.tsx
rename to packages/docs/src/components/Elements/ElementPage.tsx
index e7d83ad2cb..f41700dbd1 100644
--- a/packages/docs/src/components/Examples/ExamplePage.tsx
+++ b/packages/docs/src/components/Elements/ElementPage.tsx
@@ -1,7 +1,7 @@
import React, {type ComponentType, type ReactNode} from 'react';
-import {ExamplePreview} from './ExamplePreview';
+import {ElementPreview} from './ElementPreview';
-type ExamplePageProps = {
+type ElementPageProps = {
readonly component: ComponentType<Record<string, never>>;
readonly durationInFrames: number;
readonly fps: number;
@@ -10,7 +10,7 @@ type ExamplePageProps = {
readonly children: ReactNode;
};
-export const ExamplePage: React.FC<ExamplePageProps> = ({
+export const ElementPage: React.FC<ElementPageProps> = ({
children,
component,
durationInFrames,
@@ -21,7 +21,7 @@ export const ExamplePage: React.FC<ExamplePageProps> = ({
return (
<>
<h2>Preview</h2>
- <ExamplePreview
+ <ElementPreview
component={component}
durationInFrames={durationInFrames}
fps={fps}
diff --git a/packages/docs/src/components/Examples/ExamplePreview.tsx b/packages/docs/src/components/Elements/ElementPreview.tsx
similarity index 89%
rename from packages/docs/src/components/Examples/ExamplePreview.tsx
rename to packages/docs/src/components/Elements/ElementPreview.tsx
index 58480db50a..a3351e8d10 100644
--- a/packages/docs/src/components/Examples/ExamplePreview.tsx
+++ b/packages/docs/src/components/Elements/ElementPreview.tsx
@@ -1,7 +1,7 @@
import {Player} from '@remotion/player';
import React, {type ComponentType} from 'react';
-type ExamplePreviewProps = {
+type ElementPreviewProps = {
readonly component: ComponentType<Record<string, never>>;
readonly durationInFrames: number;
readonly fps: number;
@@ -9,7 +9,7 @@ type ExamplePreviewProps = {
readonly height: number;
};
-export const ExamplePreview: React.FC<ExamplePreviewProps> = ({
+export const ElementPreview: React.FC<ElementPreviewProps> = ({
component,
durationInFrames,
fps,
diff --git a/packages/docs/src/test/examples.test.ts b/packages/docs/src/test/elements.test.ts
similarity index 68%
rename from packages/docs/src/test/examples.test.ts
rename to packages/docs/src/test/elements.test.ts
index b1a342261d..04583599d3 100644
--- a/packages/docs/src/test/examples.test.ts
+++ b/packages/docs/src/test/elements.test.ts
@@ -2,10 +2,10 @@ import {describe, expect, test} from 'bun:test';
import {existsSync, readdirSync, readFileSync, statSync} from 'fs';
import path from 'path';
-const examplesRoot = path.join(__dirname, '..', '..', 'examples');
-const templateRoot = path.join(__dirname, '..', '..', 'examples-template');
+const elementsRoot = path.join(__dirname, '..', '..', 'elements');
+const templateRoot = path.join(__dirname, '..', '..', 'elements-template');
-// Exports every example source file must define so that the colocated MDX page
+// Exports every element source file must define so that the colocated MDX page
// can import them and pass them to <Player>.
const requiredExports = [
'durationInFrames',
@@ -15,14 +15,14 @@ const requiredExports = [
'RemotionRoot',
];
-type Example = {
+type Element = {
name: string;
mdxPath: string;
tsxPath: string;
};
-const findExamples = (root: string): Example[] => {
- const examples: Example[] = [];
+const findElements = (root: string): Element[] => {
+ const elements: Element[] = [];
const walk = (dir: string) => {
const indexMdx = path.join(dir, 'index.mdx');
@@ -31,7 +31,7 @@ const findExamples = (root: string): Example[] => {
(f) => f.endsWith('.tsx') && !f.endsWith('.test.tsx'),
);
if (tsxFiles.length > 0) {
- examples.push({
+ elements.push({
name: path.relative(root, dir) || path.basename(dir),
mdxPath: indexMdx,
tsxPath: path.join(dir, tsxFiles[0]),
@@ -49,7 +49,7 @@ const findExamples = (root: string): Example[] => {
};
walk(root);
- return examples;
+ return elements;
};
// Extracts the first ```tsx fenced code block from an MDX file.
@@ -58,20 +58,20 @@ const extractTsxBlock = (mdx: string): string | null => {
return match ? match[1] : null;
};
-const allExamples = [
- ...findExamples(examplesRoot),
- ...findExamples(templateRoot),
+const allElements = [
+ ...findElements(elementsRoot),
+ ...findElements(templateRoot),
];
-describe('Examples must follow the colocated single-file format', () => {
- test('at least one example exists', () => {
- expect(allExamples.length).toBeGreaterThan(0);
+describe('Elements must follow the colocated single-file format', () => {
+ test('at least one element exists', () => {
+ expect(allElements.length).toBeGreaterThan(0);
});
- for (const example of allExamples) {
- describe(example.name, () => {
- const tsx = readFileSync(example.tsxPath, 'utf8');
- const mdx = readFileSync(example.mdxPath, 'utf8');
+ for (const element of allElements) {
+ describe(element.name, () => {
+ const tsx = readFileSync(element.tsxPath, 'utf8');
+ const mdx = readFileSync(element.mdxPath, 'utf8');
test('source file defines the required exports', () => {
for (const exp of requiredExports) {
@@ -81,8 +81,8 @@ describe('Examples must follow the colocated single-file format', () => {
expect(tsx).toContain('<Composition');
});
- test('MDX uses the ExamplePage template', () => {
- expect(mdx).toContain('ExamplePage');
+ test('MDX uses the ElementPage template', () => {
+ expect(mdx).toContain('ElementPage');
});
test('MDX imports the colocated source module', () => {