Make a component interactivev4.0.530
Remotion's default components are already interactive, meaning they can be selected and edited in the Studio.
To make your component interactive too, wrap it with Interactive.withSchema().
Create the component
For a scene that fills its parent, use layout: 'absolute-fill' when wrapping it with Interactive.withSchema(). Its inner component can return a fragment; the wrapper handles styles, transforms, premounting, and cropping.
A component with its own size, like the badge below, keeps the default layout and forwards style to its visual root.
Badge.tsximport typeReact from 'react'; typeBadgeProps = { readonlychildren ?:React .ReactNode ; readonlycolor ?: string; readonlypadding ?: number; readonlystyle ?:React .CSSProperties ; }; export constBadgeInner :React .FC <BadgeProps > = ({children ,color = '#0b84ff',padding = 16,style }) => { return ( <div style ={{ ...style ,display : 'inline-flex',borderRadius : 999,backgroundColor :color ,color : 'white',fontWeight : 700,padding , }} > {children } </div > ); };
Create a schema
Define an InteractivitySchema to declare the props that may be interactively edited.
Badge.tsximport type {InteractivitySchema } from 'remotion'; constbadgeSchema = {color : {type : 'color',default : '#0b84ff',description : 'Color', },padding : {type : 'number',min : 0,step : 1,default : 16,description : 'Padding',hiddenFromList : false, }, } asconst satisfiesInteractivitySchema ;
Interactive.withSchema() includes these schemas:
Interactive.baseSchema:durationInFrames,from,trimBefore,playbackRate,freeze,hidden,nameandshowInTimeline.Interactive.premountSchema:premountForandpostmountFor.Interactive.cropSchema:cropLeft,cropRight,cropTopandcropBottom.Interactive.transformSchema:style.transformOrigin,style.translate,style.scale,style.rotateandstyle.opacity.
Caption fieldsv4.0.500
Include Interactive.captionsSchema when the component accepts captions: Caption[] data:
Captions.tsximport {Interactive , typeInteractivitySchema } from 'remotion'; constcaptionsSchema = { ...Interactive .captionsSchema , } asconst satisfiesInteractivitySchema ;
Captions will become editable in the Studio.
Turn on interactivity
Call Interactive.withSchema() to link the schema to the component.
Badge.tsximport typeReact from 'react'; import {Interactive , typeInteractivitySchema } from 'remotion'; typeBadgeProps = { readonlychildren ?:React .ReactNode ; readonlycolor ?: string; readonlypadding ?: number; readonlystyle ?:React .CSSProperties ; }; constBadgeInner :React .FC <BadgeProps > = ({children ,color = '#0b84ff',padding = 16,style }) => { return ( <div style ={{ ...style ,display : 'inline-flex',borderRadius : 999,backgroundColor :color ,color : 'white',fontWeight : 700,padding , }} > {children } </div > ); }; constbadgeSchema = {color : {type : 'color',default : '#0b84ff',description : 'Color', },padding : {type : 'number',min : 0,step : 1,default : 16,description : 'Padding',hiddenFromList : false, }, } asconst satisfiesInteractivitySchema ; export constBadge =Interactive .withSchema ({Component :BadgeInner ,componentName : 'Badge',schema :badgeSchema ,wrapInSequence : true, });
Use the component
You can now use the component regularly.
In the Studio, it will render an outline and its props become editable.
MyComp.tsximport {Badge} from './Badge'; export const MyComp = () => { return ( <Badge from={30} durationInFrames={90} premountFor={30} color="#ff5c7a" cropLeft={0.2} style={{translate: '120px 80px'}}> Sale </Badge> ); };