Skip to content

🎥 Make videos programmatically with React

lottie skill

Jonny Burgeraa9030e445be
diff --git a/bun.lock b/bun.lock
index dc1c5b9b70..d45619413e 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1271,7 +1271,9 @@
"@remotion/bundler": "workspace:*",
"@remotion/cli": "workspace:*",
"@remotion/eslint-config-internal": "workspace:*",
+ "@remotion/lottie": "workspace:*",
"@remotion/shapes": "workspace:*",
+ "@typescript/native-preview": "catalog:",
"eslint": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
diff --git a/packages/skills/package.json b/packages/skills/package.json
index 29eb2d29f6..e15138e51a 100644
--- a/packages/skills/package.json
+++ b/packages/skills/package.json
@@ -13,6 +13,8 @@
"react": "catalog:",
"react-dom": "catalog:",
"@remotion/shapes": "workspace:*",
- "@remotion/cli": "workspace:*"
+ "@remotion/cli": "workspace:*",
+ "@typescript/native-preview": "catalog:",
+ "@remotion/lottie": "workspace:*"
}
}
diff --git a/packages/skills/skills/charts/SKILL.md b/packages/skills/skills/charts/SKILL.md
index 66c7e70dc5..b5ba87a6fc 100644
--- a/packages/skills/skills/charts/SKILL.md
+++ b/packages/skills/skills/charts/SKILL.md
@@ -109,3 +109,4 @@ For full working code examples, see:
- [Gold Price Chart Example](../example-gold-price-chart/SKILL.md) - Bar chart with Y-axis labels and staggered springs
- [Progress Bar Example](../example-progress-bar/SKILL.md) - Loading bar from 0 to 100%
- [Counter Animation Example](../example-counter/SKILL.md) - Animated number counters
+- [Animated Shapes Example](assets/animated-shapes.tsx) - Bouncing and rotating SVG shapes with spring animations
diff --git a/packages/skills/skills/example-animated-shapes/assets/example.tsx b/packages/skills/skills/charts/assets/animated-shapes.tsx
similarity index 100%
rename from packages/skills/skills/example-animated-shapes/assets/example.tsx
rename to packages/skills/skills/charts/assets/animated-shapes.tsx
diff --git a/packages/skills/skills/example-animated-shapes/SKILL.md b/packages/skills/skills/example-animated-shapes/SKILL.md
deleted file mode 100644
index 437ee05d13..0000000000
--- a/packages/skills/skills/example-animated-shapes/SKILL.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-name: example-animated-shapes
-description: Complete working example of bouncing and rotating SVG shapes (circle, triangle, rect, star) with spring animations using @remotion/shapes.
-metadata:
- category: Other
- durationInFrames: 180
- fps: 30
----
-
-## Animated Shapes Example
-
-Bouncing and rotating SVG shapes with spring animations.
-
-See the full implementation in [assets/example.tsx](assets/example.tsx).
-
-### Key Features
-
-- Uses @remotion/shapes components (Circle, Triangle, Rect, Star)
-- Staggered spring entrances for each shape
-- Continuous bounce animation using sine wave
-- Rotation animation for the star shape
-- Stroke and fill styling
diff --git a/packages/skills/skills/example-lottie/SKILL.md b/packages/skills/skills/example-lottie/SKILL.md
deleted file mode 100644
index 46250ac14f..0000000000
--- a/packages/skills/skills/example-lottie/SKILL.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-name: example-lottie
-description: Complete working example of loading and displaying Lottie animations from URL using @remotion/lottie.
-metadata:
- category: Animation
- durationInFrames: 180
- fps: 60
----
-
-## Lottie Animation Example
-
-Loading and displaying Lottie animations with spring entrance effects.
-
-See the full implementation in [assets/example.tsx](assets/example.tsx).
-
-### Key Features
-
-- Fetches Lottie JSON from remote URL
-- Loading state while animation loads
-- Spring-based scale and opacity entrance
-- Attribution display below animation
-- Uses @remotion/lottie component
diff --git a/packages/skills/skills/example-lottie/assets/example.tsx b/packages/skills/skills/example-lottie/assets/example.tsx
deleted file mode 100644
index fa82656d9d..0000000000
--- a/packages/skills/skills/example-lottie/assets/example.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { AbsoluteFill, useCurrentFrame, useVideoConfig, spring, interpolate } from "remotion";
-import { Lottie } from "@remotion/lottie";
-import { useState, useEffect } from "react";
-
-export const MyAnimation = () => {
- const frame = useCurrentFrame();
- const { fps } = useVideoConfig();
- const [animationData, setAnimationData] = useState(null);
-
- useEffect(() => {
- fetch("https://assets-v2.lottiefiles.com/a/73ecc94a-4ccb-4018-a710-835b9eaffeaf/OwGeQT8PCr.json")
- .then((res) => res.json())
- .then((data) => setAnimationData(data))
- .catch((err) => console.error("Failed to load Lottie:", err));
- }, []);
-
- const entrance = spring({
- frame,
- fps,
- config: { damping: 15, stiffness: 100 },
- });
-
- const scale = interpolate(entrance, [0, 1], [0.5, 1]);
- const opacity = interpolate(entrance, [0, 1], [0, 1]);
-
- if (!animationData) {
- return (
- <AbsoluteFill
- style={{
- backgroundColor: "#000000",
- justifyContent: "center",
- alignItems: "center",
- }}
- >
- <div style={{ color: "#94a3b8", fontSize: 24, fontFamily: "system-ui" }}>
- Loading animation...
- </div>
- </AbsoluteFill>
- );
- }
-
- return (
- <AbsoluteFill
- style={{
- backgroundColor: "#000000",
- justifyContent: "center",
- alignItems: "center",
- }}
- >
- <div
- style={{
- transform: `scale(${scale})`,
- opacity,
- }}
- >
- <Lottie
- animationData={animationData}
- style={{ width: 400, height: 400 }}
- />
- </div>
- <div
- style={{
- position: "absolute",
- bottom: 60,
- color: "#e2e8f0",
- fontSize: 24,
- fontFamily: "system-ui",
- opacity,
- textAlign: "center",
- }}
- >
- <div style={{ fontWeight: "bold", marginBottom: 4 }}>Glowing Fish Loader</div>
- <div style={{ fontSize: 16, color: "#94a3b8" }}>by Mau Ali on LottieFiles</div>
- </div>
- </AbsoluteFill>
- );
-};
diff --git a/packages/skills/skills/lottie/SKILL.md b/packages/skills/skills/lottie/SKILL.md
new file mode 100644
index 0000000000..c8096ebf40
--- /dev/null
+++ b/packages/skills/skills/lottie/SKILL.md
@@ -0,0 +1,71 @@
+---
+name: lottie
+description: Embedding Lottie animations in Remotion.
+metadata:
+ category: Animation
+---
+
+# Using Lottie Animations in Remotion
+
+## Prerequisites
+
+First, the @remotion/lottie package needs to be installed.
+If it is not, use the following command:
+
+```bash
+npx remotion add @remotion/lottie # If project uses npm
+bunx remotion add @remotion/lottie # If project uses bun
+yarn remotion add @remotion/lottie # If project uses yarn
+pnpm exec remotion add @remotion/lottie # If project uses pnpm
+```
+
+## Displaying a Lottie file
+
+To import a Lottie animation:
+
+- Fetch the Lottie asset
+- Wrap the loading process in `delayRender()` and `continueRender()`
+- Save the animation data in a state
+- Render the Lottie animation using the `Lottie` component from the `@remotion/lottie` package
+
+```tsx
+import {Lottie, LottieAnimationData} from '@remotion/lottie';
+import {useEffect, useState} from 'react';
+import {cancelRender, continueRender, delayRender} from 'remotion';
+
+export const MyAnimation = () => {
+ const [handle] = useState(() => delayRender('Loading Lottie animation'));
+
+ const [animationData, setAnimationData] = useState<LottieAnimationData | null>(null);
+
+ useEffect(() => {
+ fetch('https://assets4.lottiefiles.com/packages/lf20_zyquagfl.json')
+ .then((data) => data.json())
+ .then((json) => {
+ setAnimationData(json);
+ continueRender(handle);
+ })
+ .catch((err) => {
+ cancelRender(err);
+ });
+ }, [handle]);
+
+ if (!animationData) {
+ return null;
+ }
+
+ return <Lottie animationData={animationData} />;
+};
+```
+
+## Styling and animating
+
+Lottie supports the `style` prop to allow styles and animations:
+
+```tsx
+return <Lottie animationData={animationData} style={{width: 400, height: 400}} />;
+```
+
+### Example
+
+See an example in [assets/example.tsx](assets/example.tsx).
diff --git a/packages/skills/skills/lottie/assets/example.tsx b/packages/skills/skills/lottie/assets/example.tsx
new file mode 100644
index 0000000000..ee64e3c35f
--- /dev/null
+++ b/packages/skills/skills/lottie/assets/example.tsx
@@ -0,0 +1,28 @@
+import {Lottie, LottieAnimationData} from '@remotion/lottie';
+import {useEffect, useState} from 'react';
+import {cancelRender, continueRender, delayRender} from 'remotion';
+
+export const MyAnimation = () => {
+ const [handle] = useState(() => delayRender('Loading Lottie animation'));
+
+ const [animationData, setAnimationData] =
+ useState<LottieAnimationData | null>(null);
+
+ useEffect(() => {
+ fetch('https://assets4.lottiefiles.com/packages/lf20_zyquagfl.json')
+ .then((data) => data.json())
+ .then((json) => {
+ setAnimationData(json);
+ continueRender(handle);
+ })
+ .catch((err) => {
+ cancelRender(err);
+ });
+ }, [handle]);
+
+ if (!animationData) {
+ return null;
+ }
+
+ return <Lottie animationData={animationData} />;
+};
diff --git a/packages/skills/src/Root.tsx b/packages/skills/src/Root.tsx
index 3992d4508e..9339f98a76 100644
--- a/packages/skills/src/Root.tsx
+++ b/packages/skills/src/Root.tsx
@@ -3,7 +3,8 @@ import {
COMPOSITION_HEIGHT,
COMPOSITION_WIDTH,
MyAnimation,
-} from '../skills/example-animated-shapes/assets/example';
+} from '../skills/charts/assets/animated-shapes';
+import {MyAnimation as LottieAnimation} from '../skills/lottie/assets/example';
export const RemotionRoot = () => {
return (
@@ -16,6 +17,14 @@ export const RemotionRoot = () => {
width={COMPOSITION_WIDTH}
height={COMPOSITION_HEIGHT}
/>
+ <Composition
+ id="LottieAnimation"
+ component={LottieAnimation}
+ durationInFrames={150}
+ fps={30}
+ width={1080}
+ height={1080}
+ />
</>
);
};
diff --git a/packages/skills/tsconfig.json b/packages/skills/tsconfig.json
new file mode 100644
index 0000000000..78298c5703
--- /dev/null
+++ b/packages/skills/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "extends": "../tsconfig.settings.json",
+ "compilerOptions": {
+ "module": "Preserve",
+ "esModuleInterop": true,
+ "resolveJsonModule": false,
+ "skipLibCheck": true,
+ "jsx": "react-jsx",
+ "noEmit": true
+ },
+ "references": []
+}