Skip to content

🎥 Make videos programmatically with React

make documentation page for composition.md better

Jonny Burgerfbc04d980538
diff --git a/packages/docs/docs/composition.md b/packages/docs/docs/composition.md
index a075ec60bf..2874159101 100644
--- a/packages/docs/docs/composition.md
+++ b/packages/docs/docs/composition.md
@@ -7,29 +7,69 @@ This is the component to use to register a video to make it renderable and make
A composition represents the video you want to create, as a collection of clips (for example, several `<Sequence>`) that will play back to back to form your video.
+```tsx twoslash title="src/Video.tsx"
+const Component: React.FC = () => null;
+// ---cut---
+
+import { Composition } from "remotion";
+
+export const RemotionRoot: React.FC = () => {
+ return (
+ <>
+ <Composition
+ component={Component}
+ durationInFrames={300}
+ width={1080}
+ height={1080}
+ fps={30}
+ id="test-render"
+ defaultProps={{}}
+ />
+ {/* Additional compositions can be rendered */}
+ </>
+ );
+};
+```
+
## API
A `<Composition />` should be placed within a fragment of the root component (which is registered using [`registerRoot()`](/docs/register-root)).
The component takes the following props:
-- `id`: ID of the composition, as shown in the sidebar and also a unique identifier of the composition that you need to specify if you want to render it. The ID can only contain letters, numbers and `-`.
+### `id`
+
+ID of the composition, as shown in the sidebar and also a unique identifier of the composition that you need to specify if you want to render it. The ID can only contain letters, numbers and `-`.
+
+### `fps`
-- `fps`: At how many frames the composition should be rendered.
+At how many frames the composition should be rendered.
-- `durationInFrames`: How many frames the composition should be long.
+### `durationInFrames`
-- `height`: Height of the composition in pixels.
+How many frames the composition should be long.
-- `width`: Width of the composition in pixels.
+### `height`
-- `component` **or** `lazyComponent`: Pass the component in directly **or** pass a function that returns a dynamic import. Passing neither or both of the props is an error.
+Height of the composition in pixels.
+
+### `width`
+
+Width of the composition in pixels.
+
+### `component` **or** `lazyComponent`
+
+Pass the component in directly **or** pass a function that returns a dynamic import. Passing neither or both of the props is an error.
:::note
If you use `lazyComponent`, Remotion will use React Suspense to load the component. Components will be compiled by Webpack as they are needed, which will reduce startup time of Remotion. If you use `lazyComponent`, you need to use a default export for your component. This is a restriction of React Suspense.
:::
-- `defaultProps` _optional_: Give your component default props that will be shown in the preview. You can override these props during render using a CLI flag.
+### `defaultProps`
+
+_optional_
+
+Give your component default props that will be shown in the preview. You can override these props during render using a CLI flag.
:::note
Type your components using the `React.FC<{}>` type and the `defaultProps` prop will be typesafe.