--- name: remotion-markup description: Content, animation and effects best practices version: 4.0.535 --- This is guidance for writing Remotion React Markup. If this is not relevant, load Remotion Best Practices instead. ## Preserve user changes Users may make edits in the code outside of the conversation. If you detect a surprising change made in the meanwhile, don't overwrite it, assume it was intentional or ask for confirmation. ## General rules Inside a composition or scene component, get `fps` from `useVideoConfig()` for all seconds-to-frames calculations, including timing props such as `from`, `trimBefore`, `durationInFrames`, and `premountFor`. Keeping the expression on the JSX node, such as `trimBefore={4 * fps}`, lets Studio edit the timing and keeps it correct if the composition frame rate changes. Drive animations using `useCurrentFrame()` and `interpolate()`. CSS `transition` or `animation` will not render correctly, they need to refactored. Tailwind animation class will not render correctly, they need to be refactored. Use `Easing.bezier()` and `Easing.spring()` to customize timing. Structure your markup according to Remotion Interactivity Best Practices. Prefer `Interactive.withSchema({wrapInSequence: true, layout: 'absolute-fill'})` for scenes with editable props. Their inner markup can return a fragment; the wrapper handles layout and instance styles. Sized elements such as lower thirds can keep the default layout and forward `style` to their own root. Register reusable scenes as connected compositions. Put timing directly on components that support it; avoid redundant `` wrappers. Give every timed component that supports `premountFor` one second of premounting: `premountFor={fps}`, where `fps` comes from `useVideoConfig()`. Apply this to media, interactive components, ``, ``, and ``, including timed components nested inside scenes. Premount the parent timeline item too when a nested item needs to mount before the parent starts. A component without `premountFor`, such as ``, needs no substitute. The Studio edits the JSX source node that created an item. Author every composition registration, clip, scene, layer and sequence that should be editable independently as its own JSX node, with its editable props inline. Programmatic loops are suitable when the generated instances are intentionally controlled as one source template, not when users need to edit the instances separately. ```tsx import { useCurrentFrame, useVideoConfig, Easing, interpolate, Interactive } from "remotion"; export const FadeIn = () => { const frame = useCurrentFrame(); const {fps} = useVideoConfig(); return ( Hello World! ); }; ``` Keep the `interpolate()` call inline in the `style` prop. Use `scale`, `translate`, `rotate` CSS properties over `transform`. ```tsx // 👍 Inline editable keyframes and transform shorthands style={{ scale: interpolate(frame, [0, 100], [0, 1], { extrapolateLeft: 'clamp', extrapolateRight: 'clamp', easing: Easing.spring({damping: 200}), output: 'perceptual-scale' // For `scale` animations, use "output: 'perceptual-scale'" }), translate: interpolate(frame, [0, 100], ["0px 0px", "100px 100px"], { extrapolateLeft: 'clamp', extrapolateRight: 'clamp', easing: Easing.spring({damping: 200}), }), rotate: interpolate(frame, [0, 100], ["20deg", "90deg"], { extrapolateLeft: 'clamp', extrapolateRight: 'clamp', easing: Easing.spring({damping: 200}), }), }} // 👎 Non-inline values and transform strings become harder to edit in Studio const scale = interpolate(frame, [0, 100], [0, 1]); style={{ transform: `scale(${scale})`, }} ``` ## Assets Place assets in the `public/` folder at your project root. Use `staticFile()` to reference files from the `public/` folder. ## Media components Add video and audio using `