Best practices for creating Elements
An Element is a reusable React component that users copy into their video projects. These practices make Elements easy to combine and edit. To publish your Elements, see Building Element Libraries.
Example
This lower third follows the practices on this page:
lower-third.tsximport {Interactive ,interpolate ,useCurrentFrame ,useVideoConfig } from 'remotion'; export constLowerThird = () => { constframe =useCurrentFrame (); const {durationInFrames } =useVideoConfig (); return ( // Sized to its content, with its own text color <div style ={{width : 560,height : 86,color : '#ffffff',fontFamily : 'Arial, sans-serif'}}> <Interactive .Div // A named layer that users can select in Studioname ="Name bar" // Animates in and out, and the exit follows the end of the ElementcropRight ={interpolate (frame , [0, 20,durationInFrames - 24,durationInFrames - 4], [1, 0, 0, 1], {extrapolateLeft : 'clamp',extrapolateRight : 'clamp', })}style ={{width : 560,height : 86,padding : '20px 30px',backgroundColor : '#174c3c',fontSize : 40,fontWeight : 700}} > {/* Text written inline, so it can be edited in Studio */} Alex Morgan </Interactive .Div > </div > ); };
For complete Elements, see Name Lower Third, Text Marker and YouTube Comment Highlight, or the Elements in the Element Library template.
Design
Design for video, not for a web page
If you use AI to build an Element, it often designs it like a website component. Use published videos as a reference instead: video usually needs larger, simpler graphics.
- Use large text. A font size that is readable on a web page, such as 20px, is too small in a 1920x1080 video.
- Leave out links, buttons with hover states and printed URLs. Nothing in a rendered video can be clicked.
- Drive all motion with
useCurrentFrame(). CSS transitions and animations do not render correctly.
Keep it focused
Users 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.
Timing
Pick a useful default duration
Set durationInFrames to a length at which the Element looks right without changes. Users can trim or extend it afterwards.
Animate overlays in and out
Give overlays, such as lower thirds, an entrance and an exit animation.
Read durationInFrames from useVideoConfig() and count the exit from the end, as in the example. When a user trims or extends the Element, the exit follows its new end.
Keep it working when trimmed
interpolate() throws an error if its input range is not strictly increasing. A range such as [0, 20, durationInFrames - 24, durationInFrames - 4] breaks once the Element is shorter than its entrance and exit combined, here 44 frames.
Keep the entrance and exit short compared to the default duration, and trim the Element to the shortest length that still makes sense.
Make it portable
- Avoid global styles and layout side effects.
- 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.
Size
Size the Element to its smallest useful bounding box, and don't add padding for the gallery preview. Only backgrounds should fill the whole frame.
If the Element adapts to the composition, set dimensions to null.
Fonts
Web-safe fonts need no setup. Load any other font inside the Element's source, for example with @remotion/google-fonts, and declare the package as a dependency. A font that is only loaded by the library's website is missing in the user's project, and the Element falls back to a default font.
Dependencies
Minimize dependencies, and declare them as described in the dependencies field.
Assets
Include assets that should be copied into the user's project, as described in the asset handling guidance.
Keep the source self-contained
An Element is one file with one exported component. Helpers that live elsewhere in the library must be copied into it.
Remove unused imports, variables and helpers. Remotion's templates enable strict TypeScript checks, so leftover code fails the user's type check.
Make it editable in Studio
Expose layers with Interactive
Where possible, expose the Element's layers so users can edit them with Studio interactivity. Follow the interactivity best practices:
- Give each part that users edit separately its own
Interactivenode with a descriptivename, such asName bar. - Write text inline in a named layer. Text passed as a prop is only editable in Studio if the component exposes it through
Interactive.create(). - Animate the parts inside the Element, not its root. Studio sets the position, so the user can move the Element and the animation moves with it. Animating the opacity or position of the root makes those properties read-only in the Inspector.
Choose an installation mode
Pick an installation mode based on what users should see in Studio.
Separate editable layers
installationMode: 'wrapped' is the default. Studio wraps the component in a <Sequence> that sets its placement and duration, and the layers inside stay editable through their Interactive call sites.
One interactive object
Use installationMode: 'component-owned-sequence' when editing the internal parts doesn't make sense, for example for generative effects, canvas drawings, or a single image overlay. It is not meant for hiding markup that users could edit.
Wrap the exported component in Interactive.create() and export it directly, without another wrapper. The component must accept a style prop and apply it to its visual root.
Caption styles always use this mode and have additional requirements.
Expose useful controls
Users get a copy of the Element's source and can edit it directly, so the Interactive schema doesn't need to expose every detail. Add controls with Interactive.create() where they make the Element easier to edit. Controls can tune the look, but shouldn't switch between unrelated styles.
Initial props
If the Element needs starter props, provide initialProps in its library metadata. Studio writes them onto the installed component in both installation modes.
Users can always edit these props in the source. They only show up in the Inspector if the component exposes them through Interactive.create().
Test before publishing
Install the Element into a new project, for example one created with npx create-video@latest --blank, using npx remotion elements use. Then check that:
- the project's type check and lint pass without changes to the Element
- the Element shows up in Studio with the expected layers, and can be moved
- trimming it short and extending it does not break the animation
- it still works when added near the end of the composition
- fonts and assets load
See Test the integration for testing the library website.
Help and feedback
Questions about building Elements and feedback on work in progress are welcome in the #elements channel on Discord.