🎥 Make videos programmatically with React
Elements: Move gallery and protocol details out of Element guidelines
Igor Samokhovetsc67c9b94a6e5
diff --git a/packages/docs/docs/studio-protocol/component-library-integration.mdx b/packages/docs/docs/studio-protocol/component-library-integration.mdxindex 2e44ac400d..8ef8caf9e9 100644--- a/packages/docs/docs/studio-protocol/component-library-integration.mdx+++ b/packages/docs/docs/studio-protocol/component-library-integration.mdx@@ -9,8 +9,7 @@ crumb: '@remotion/studio-protocol'An Element contains the source code for one component. It also contains the data that Studio needs to insert the component.-Studio writes the source code to an `.element.tsx` file. Studio installs only the packages in the Element's `dependencies` list. You do not have to publish or install the Element Library in the target project.-+Studio writes the source code to an `.element.tsx` file. Studio installs only the packages in the Element's `dependencies` list.A component that follows the [Element guidelines](/elements/guidelines) is usually ready for Studio.Use this procedure to preview and deliver a component:@@ -29,19 +28,15 @@ Import the component normally for the preview. The website bundler then compilesUse the same dimensions and duration in the Player and the Element payload.-### Preview installed assets<AvailableFrom v="4.0.528" />--Accept image, audio, and video URLs as component props, rather than hardcoding preview URLs or installed file paths in the source.--Pass normal URL strings to the Player. These may point to assets served by your preview website or, if you prefer, hosted elsewhere. The preview location does not need to match the installed asset path.+### Asset handling<AvailableFrom v="4.0.528" />-For assets that should be copied into the user's project, declare them in the payload's [`assets`](/docs/studio-protocol/create-element-payload#assets). Choose public-relative paths scoped to the component, such as `my-element/logo.png`, to reduce collisions with other components.+Images, audio, and video that your preview loads from URLs can be downloaded into the user's `public` folder when they install the Element, or keep loading from their URLs.-In the payload's `initialProps`, replace each corresponding URL with [`staticFileRef()`](/docs/studio-protocol/static-file-ref), referencing the declared asset path. Keep these references out of the Player's `inputProps`: they are installation metadata, not runtime URLs. See the [`staticFileRef()` example](/docs/studio-protocol/static-file-ref#example) for the complete payload and generated code.+Pass each asset to the component as a prop, such as `src`, instead of hardcoding its URL. Your preview passes the URL. The installed Element gets either `src={staticFile('my-element/logo.png')}` or the same URL. The component source doesn't change.-Studio saves the assets into the public directory and generates [`staticFile()`](/docs/staticfile) expressions on the component invocation. The Element source stays unchanged. This works in both installation modes.+To download an asset, declare it in the payload's [`assets`](/docs/studio-protocol/create-element-payload#assets) and replace its URL in the payload's `initialProps` with [`staticFileRef()`](/docs/studio-protocol/static-file-ref). Studio saves the file and passes it to the component with [`staticFile()`](/docs/staticfile). See the [`staticFileRef()` example](/docs/studio-protocol/static-file-ref#example).-For assets that should remain remote after installation, keep URL strings in `initialProps` instead of using references. Those assets continue to depend on the remote host.+To keep an asset remote, leave its URL in `initialProps`.## Reuse component codediff --git a/packages/docs/elements/contributing.mdx b/packages/docs/elements/contributing.mdxindex f9dc25fa1c..47eaa1903e 100644--- a/packages/docs/elements/contributing.mdx+++ b/packages/docs/elements/contributing.mdx@@ -20,14 +20,16 @@ cd packages/docs && bun remotionThe **scaffold-element skill** is an [Agent Skill](https://agentskills.io/) that can set up the template and Studio composition.-Declare the Element's dependencies in `element-definitions.ts` as described in the [Element guidelines](/elements/guidelines#dependencies).+Declare the Element's dependencies in `element-definitions.ts` as described in the [`dependencies` field](/docs/studio-protocol/create-element-payload#dependencies).If the Element needs starter props, put them in `initial-props.ts`, type them with `satisfies ComponentProps<typeof YourComponent>`, and register them as `initialProps` in `element-definitions.ts`.-For installed assets, declare `assets` in `element-definitions.ts` and put `staticFileRef()` references in `installationProps`. Keep preview URLs in `initialProps`. For Elements without installed assets, use `assets: []` and `installationProps: null`.+For installed assets, declare `assets` in `element-definitions.ts` and put `staticFileRef()` references in `installationProps`. Keep preview URLs in `initialProps`. For Elements without installed assets, use `assets: []` and `installationProps: null`. `installationProps` shallowly overrides `initialProps` only for installation; an overridden object or array replaces that entire prop.## 2. Prepare previews+Choose a poster frame that clearly shows the Element. The video preview should cover the Element's full duration and, when applicable, include its entrance and exit animations.+Render and visually review the Element and its previews:```bash title="Terminal"diff --git a/packages/docs/elements/guidelines.mdx b/packages/docs/elements/guidelines.mdxindex e658bb4886..4669609636 100644--- a/packages/docs/elements/guidelines.mdx+++ b/packages/docs/elements/guidelines.mdx@@ -6,20 +6,20 @@ description: Design reusable Remotion Elements for any Element library.# Element Guidelines-These guidelines cover how to design, build, and publish an Element that users can copy into their projects.+These guidelines cover how to design and build an Element that users can copy into their projects. They apply to the official gallery and to your own Element Library. To let users install Elements from your library's website, see [Integrating an Element Library with Studio](/docs/studio-protocol/component-library-integration).## Design### Use real videos as references-If you use AI to build an Element, it often designs it like a website component, sized and styled for a page rather than a video. Published videos make a better reference. In a video, text and graphics usually need to be larger so viewers can read them at a glance, and simpler designs tend to work better.+If you use AI to build an Element, it often designs it like a website component, sized and styled for a page rather than a video.++Use published videos as a reference instead: video usually needs larger, simpler graphics.### Keep it focusedUsers add Elements to their own projects and combine them into a larger video. This works best when each Element does one thing. An Element that bundles several things, such as a title with its own background, is harder to fit in.-Aim for one visual treatment, technique, or workflow per Element, ideally one that works without configuration and fits many projects. A preset, a small CSS change, or a different set of Studio control values usually doesn't need its own Element.-### Animate temporary Elements in and outIf an Element appears over other content for a short time, such as a lower third, give it an entrance and an exit animation. Backgrounds don't need them.@@ -30,24 +30,18 @@ Animate the parts inside the Element, not its position on screen. Studio sets th### Make it portable-- Keep the implementation self-contained, using HTML, CSS, and React where possible.-- Avoid global styles, layout side effects, and fullscreen assumptions unless the Element is a background.-- Set explicit defaults for inherited visual properties, so the Element looks the same under light and dark host themes:- - Set text colors on the Element root or the nearest visual surface instead of relying on browser or host-page defaults.- - Make sure every use of `currentColor` resolves from an ancestor with an explicit color.+- Avoid global styles and layout side effects.+- Don't make the Element fill the whole frame unless it's a background.+- Set a text color on the Element itself. Otherwise it inherits the page's color, including through `currentColor`, which changes between light and dark themes.- Avoid project-specific branding or footage, and make colors easy to change.### Dependencies-Minimize dependencies.--Declare every external dependency in the Element library's metadata, except `react`, `react-dom`, and `remotion`. Every non-Remotion package must use an exact semantic version; version ranges and tags are not accepted. Remotion packages use `version: null` and are installed at the project's Remotion version. See the [Studio protocol's `dependencies` field](/docs/studio-protocol/create-element-payload#dependencies).+Minimize dependencies, and declare them as described in the [`dependencies` field](/docs/studio-protocol/create-element-payload#dependencies).### Assets-Include assets that should be copied into the user's project. Use Google Fonts for non-websafe fonts.--Follow the [asset integration guidance](/docs/studio-protocol/component-library-integration#preview-installed-assets). Installed assets are separate from gallery previews. Declare installed assets in the library metadata and use [`staticFileRef()`](/docs/studio-protocol/static-file-ref) references in `installationProps`. Keep preview URLs in `initialProps`.+Include assets that should be copied into the user's project, as described in the [asset handling guidance](/docs/studio-protocol/component-library-integration#asset-handling). Use Google Fonts for non-websafe fonts.## Integrate with Studio@@ -79,12 +73,4 @@ Give editable objects clear names. Use a generic name such as `Container` for thIf the Element needs starter props, provide [`initialProps`](/docs/studio-protocol/create-element-payload#initialprops) in its library metadata. For `component-owned-sequence`, this can provide defaults for Inspector controls. Otherwise, users can edit the installed source directly.-`installationProps` shallowly overrides `initialProps` only for installation; an overridden object or array replaces that entire prop.--## Publish--### Choose a representative preview--Choose a poster frame that clearly shows the Element. The video preview should cover the Element's full duration and, when applicable, include its entrance and exit animations.-To submit an Element to the official gallery, read the [contribution guide](/elements/contributing).