$npx -y skills add MoizIbnYousaf/marketing-cli --skill docs-demoAdd an interactive demo to the Remotion documentation. Use when creating a new <Demo> component for docs pages.
| 1 | # Adding an Interactive Demo to Docs |
| 2 | |
| 3 | Interactive demos render a Remotion composition inline in documentation pages using `@remotion/player`. They live in `packages/docs/components/demos/`. |
| 4 | |
| 5 | ## Steps |
| 6 | |
| 7 | 1. **Create a component** in `packages/docs/components/demos/` (e.g. `MyDemo.tsx`). It should be a standard React component using Remotion hooks like `useCurrentFrame()` and `useVideoConfig()`. |
| 8 | |
| 9 | 2. **Register the demo** in `packages/docs/components/demos/types.ts`: |
| 10 | - Import the component |
| 11 | - Export a `DemoType` object with these fields: |
| 12 | - `id`: unique string used in `<Demo type="..." />` |
| 13 | - `comp`: the React component |
| 14 | - `compWidth` / `compHeight`: canvas dimensions (e.g. 1280x720) |
| 15 | - `fps`: frame rate (typically 30) |
| 16 | - `durationInFrames`: animation length |
| 17 | - `autoPlay`: whether it plays automatically |
| 18 | - `options`: array of interactive controls (can be empty `[]`) |
| 19 | |
| 20 | 3. **Add to the demos array** in `packages/docs/components/demos/index.tsx`: |
| 21 | - Import the demo constant from `./types` |
| 22 | - Add it to the `demos` array |
| 23 | |
| 24 | 4. **Use in MDX** with `<Demo type="your-id" />` |
| 25 | |
| 26 | ## Options |
| 27 | |
| 28 | Options add interactive controls below the player. Each option needs `name` and `optional` (`'no'`, `'default-enabled'`, or `'default-disabled'`). |
| 29 | |
| 30 | Supported types: |
| 31 | |
| 32 | - `type: 'numeric'` — slider with `min`, `max`, `step`, `default` |
| 33 | - `type: 'boolean'` — checkbox with `default` |
| 34 | - `type: 'enum'` — dropdown with `values` array and `default` |
| 35 | - `type: 'string'` — text input with `default` |
| 36 | |
| 37 | Option values are passed to the component as `inputProps`. Access them as regular React props. |
| 38 | |
| 39 | ## Example registration |
| 40 | |
| 41 | ```ts |
| 42 | export const myDemo: DemoType = { |
| 43 | comp: MyDemoComp, |
| 44 | compHeight: 720, |
| 45 | compWidth: 1280, |
| 46 | durationInFrames: 150, |
| 47 | fps: 30, |
| 48 | id: 'my-demo', |
| 49 | autoPlay: true, |
| 50 | options: [], |
| 51 | }; |
| 52 | ``` |