Skip to content

🎥 Make videos programmatically with React

Add automatic Interactive.withSchema wrapping

JonnyBurger385131791f7a
diff --git a/packages/codemods/src/basic-captions-element-source.ts b/packages/codemods/src/basic-captions-element-source.ts
index 9a1ade51c0..af824ce25a 100644
--- a/packages/codemods/src/basic-captions-element-source.ts
+++ b/packages/codemods/src/basic-captions-element-source.ts
@@ -5,30 +5,23 @@ import {createTikTokStyleCaptions} from '@remotion/captions';
import React, {useMemo} from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type BasicCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
- Pick<SequenceProps, 'from' | 'durationInFrames' | 'trimBefore' | 'width' | 'height'> & {
+type BasicCaptionsProps = InteractiveTransformProps &
+ Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
- readonly playbackRate?: number;
readonly combineTokensWithinMilliseconds?: number;
};
const BasicCaptionsContent: React.FC<{
readonly captions: Caption[];
- readonly playbackRate: number;
- readonly trimBefore: number;
readonly combineTokensWithinMilliseconds: number;
-}> = ({captions, playbackRate, trimBefore, combineTokensWithinMilliseconds}) => {
+}> = ({captions, combineTokensWithinMilliseconds}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const pages = useMemo(
@@ -39,9 +32,7 @@ const BasicCaptionsContent: React.FC<{
}).pages,
[captions, combineTokensWithinMilliseconds],
);
- // The Sequence frame already includes trimBefore; only elapsed frames speed up.
- const currentTimeMs =
- ((trimBefore + (frame - trimBefore) * playbackRate) / fps) * 1000;
+ const currentTimeMs = (frame / fps) * 1000;
const page = pages.find(
(candidate) =>
currentTimeMs >= candidate.startMs &&
@@ -77,7 +68,6 @@ const BasicCaptionsContent: React.FC<{
};
const basicCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -106,63 +96,43 @@ const basicCaptionsSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const BasicCaptionsInner: React.FC<
- BasicCaptionsProps & {readonly controls: SequenceControls | undefined}
-> = ({
+const BasicCaptionsInner: React.FC<BasicCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = 2000,
- controls,
- durationInFrames,
- from,
height = 220,
- name,
- playbackRate = 1,
style,
- trimBefore,
width = 900,
- ...interactiveProps
}) => {
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? 'Basic captions'}
- from={from}
- durationInFrames={durationInFrames}
- trimBefore={trimBefore}
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+ position: 'absolute',
+ bottom: 120,
+ left: '50%',
+ transform: 'translateX(-50%)',
+ width,
+ height,
+ ...style,
+ }}
>
- <div
- style={{
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- position: 'absolute',
- bottom: 120,
- left: '50%',
- transform: 'translateX(-50%)',
- width,
- height,
- ...style,
- }}
- >
- <BasicCaptionsContent
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
+ <BasicCaptionsContent
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ />
+ </div>
);
};
export const BasicCaptions = Interactive.withSchema({
Component: BasicCaptionsInner,
componentName: '<BasicCaptions>',
+ defaultSequenceName: 'Basic captions',
schema: basicCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<BasicCaptionsProps>;
+ wrapInSequence: true,
+});
`;
export const getBasicCaptionsElementFile = ({
diff --git a/packages/core/src/Interactive.tsx b/packages/core/src/Interactive.tsx
index 94543b2cb2..93cb415da3 100644
--- a/packages/core/src/Interactive.tsx
+++ b/packages/core/src/Interactive.tsx
@@ -22,7 +22,7 @@ import {
type InteractivitySchema,
} from './interactivity-schema.js';
import {resolveSequenceDuration} from './resolve-sequence-duration.js';
-import {Sequence} from './Sequence.js';
+import {Sequence, SequenceWithoutSchema} from './Sequence.js';
import type {AbsoluteFillLayout, SequenceProps} from './Sequence.js';
import {useCropStyle} from './use-crop-style.js';
import {usePremounting} from './use-premounting.js';
@@ -218,13 +218,230 @@ const setRef = <ElementType,>(
}
};
-const withSchema = <S extends InteractivitySchema, Props extends object>(
- options: WithInteractivitySchemaOptions<S, Props>,
-): React.ComponentType<Props> => {
- const Wrapped = withInteractivitySchema(options);
+type NonIntrinsicComponent<Component extends React.ElementType> = Component &
+ React.ComponentType<React.ComponentProps<Component>>;
+
+type KeysOfUnion<Props> = Props extends unknown ? keyof Props : never;
+
+type ComponentWithoutReservedProps<
+ Component extends React.ElementType,
+ ReservedKey extends PropertyKey,
+> = NonIntrinsicComponent<Component> &
+ (Extract<
+ KeysOfUnion<React.ComponentPropsWithoutRef<Component>>,
+ ReservedKey
+ > extends never
+ ? unknown
+ : never);
+
+type AutomaticWrapperReservedKey = keyof InteractiveBaseProps | 'controls';
+
+type CroppingWrapperReservedKey =
+ | AutomaticWrapperReservedKey
+ | keyof InteractiveCropProps;
+
+type IsAny<Value> = 0 extends 1 & Value ? true : false;
+
+type StyleMemberAcceptsCssProperties<Style> =
+ IsAny<Style> extends true
+ ? true
+ : Style extends unknown
+ ? [Style] extends [null | undefined]
+ ? false
+ : Exclude<keyof React.CSSProperties, keyof Style> extends never
+ ? React.CSSProperties extends Style
+ ? true
+ : false
+ : false
+ : never;
+
+type StyleAcceptsCssProperties<Style> =
+ true extends StyleMemberAcceptsCssProperties<Style> ? true : false;
+
+type PropsBranchAcceptsStyle<Props> = Props extends unknown
+ ? 'style' extends keyof Props
+ ? StyleAcceptsCssProperties<Props[Extract<'style', keyof Props>]>
+ : false
+ : never;
+
+type EveryPropsBranchAcceptsStyle<Props> = [Props] extends [never]
+ ? false
+ : false extends PropsBranchAcceptsStyle<Props>
+ ? false
+ : true;
+
+type ComponentAcceptingStyle<Component extends React.ElementType> =
+ ComponentWithoutReservedProps<Component, CroppingWrapperReservedKey> &
+ (EveryPropsBranchAcceptsStyle<
+ React.ComponentPropsWithoutRef<Component>
+ > extends true
+ ? unknown
+ : never);
+
+type WithSchema = {
+ <S extends InteractivitySchema, Component extends React.ElementType>(
+ options: Omit<
+ WithInteractivitySchemaOptions<
+ S,
+ React.ComponentPropsWithoutRef<Component>
+ >,
+ 'Component' | 'supportsEffects'
+ > & {
+ readonly Component: ComponentWithoutReservedProps<
+ Component,
+ AutomaticWrapperReservedKey
+ >;
+ readonly defaultDurationInFrames?: number;
+ readonly defaultSequenceName?: string;
+ readonly wrapInSequence: true;
+ },
+ ): React.FC<React.ComponentPropsWithRef<Component> & InteractiveBaseProps>;
+ <S extends InteractivitySchema, Component extends React.ElementType>(
+ options: Omit<
+ WithInteractivitySchemaOptions<
+ S,
+ React.ComponentPropsWithoutRef<Component>
+ >,
+ 'Component' | 'supportsEffects'
+ > & {
+ readonly Component: ComponentAcceptingStyle<Component>;
+ readonly defaultDurationInFrames?: number;
+ readonly defaultSequenceName?: string;
+ readonly wrapInSequence: {readonly cropping: true};
+ },
+ ): React.FC<
+ React.ComponentPropsWithRef<Component> &
+ InteractiveBaseProps &
+ InteractiveCropProps
+ >;
+ <S extends InteractivitySchema, Props extends object>(
+ options: WithInteractivitySchemaOptions<S, Props> & {
+ readonly wrapInSequence?: false;
+ },
+ ): React.ComponentType<Props>;
+};
+
+type WithSchemaImplementationOptions = Omit<
+ WithInteractivitySchemaOptions<InteractivitySchema, object>,
+ 'Component'
+> & {
+ readonly Component: React.ComponentType<object>;
+ readonly defaultDurationInFrames?: number;
+ readonly defaultSequenceName?: string;
+ readonly wrapInSequence?: false | true | {readonly cropping: true};
+};
+
+const withSchema: WithSchema = (untypedOptions: unknown) => {
+ const options = untypedOptions as WithSchemaImplementationOptions;
+ if (!options.wrapInSequence) {
+ const ManualWrapped = withInteractivitySchema(
+ options as WithInteractivitySchemaOptions<InteractivitySchema, object>,
+ );
+ addSequenceStackTraces(ManualWrapped);
+
+ return ManualWrapped as React.FC<
+ React.ComponentProps<typeof ManualWrapped>
+ >;
+ }
+
+ const {
+ Component,
+ componentName,
+ defaultDurationInFrames,
+ defaultSequenceName,
+ schema,
+ wrapInSequence: _,
+ ...rest
+ } = options;
+ const cropping =
+ typeof options.wrapInSequence === 'object' &&
+ options.wrapInSequence.cropping;
+ type ComponentWrappedInSequenceProps = React.ComponentProps<
+ typeof Component
+ > &
+ InteractiveBaseProps & {
+ readonly controls: SequenceControls | undefined;
+ };
+ const ComponentWrappedInSequence = forwardRef<
+ unknown,
+ ComponentWrappedInSequenceProps
+ >((props, ref) => {
+ const {
+ durationInFrames,
+ from,
+ trimBefore,
+ playbackRate,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+ ...componentProps
+ } = props;
+ const {
+ cropLeft,
+ cropRight,
+ cropTop,
+ cropBottom,
+ style,
+ ...componentPropsWithoutCropping
+ } = componentProps as InteractiveCropProps & {
+ readonly style?: React.CSSProperties;
+ readonly [key: string]: unknown;
+ };
+ const croppedStyle = useCropStyle({
+ cropLeft: cropping ? cropLeft : undefined,
+ cropRight: cropping ? cropRight : undefined,
+ cropTop: cropping ? cropTop : undefined,
+ cropBottom: cropping ? cropBottom : undefined,
+ style: cropping ? (style ?? null) : null,
+ componentName,
+ });
+ const propsForComponent = cropping
+ ? {
+ ...componentPropsWithoutCropping,
+ style: croppedStyle ?? undefined,
+ }
+ : componentProps;
+
+ return (
+ <SequenceWithoutSchema
+ layout="none"
+ durationInFrames={durationInFrames ?? defaultDurationInFrames}
+ from={from}
+ trimBefore={trimBefore}
+ playbackRate={playbackRate}
+ loop={loop}
+ freeze={freeze}
+ hidden={hidden}
+ name={name ?? defaultSequenceName ?? componentName}
+ showInTimeline={showInTimeline}
+ controls={controls}
+ >
+ {React.createElement(Component, {
+ ...propsForComponent,
+ ref,
+ } as React.ComponentProps<typeof Component>)}
+ </SequenceWithoutSchema>
+ );
+ });
+ const Wrapped = withInteractivitySchema({
+ ...rest,
+ Component: ComponentWrappedInSequence,
+ componentName: defaultSequenceName ?? componentName,
+ schema: {
+ ...schema,
+ ...baseSchema,
+ ...(cropping ? cropSchema : {}),
+ },
+ supportsEffects: false,
+ });
addSequenceStackTraces(Wrapped);
- return Wrapped;
+ return Wrapped as React.FC<
+ React.ComponentProps<typeof Component> & InteractiveBaseProps
+ >;
};
const makeInteractiveElement = <Tag extends InteractiveTag>(
diff --git a/packages/docs/docs/interactive-with-schema.mdx b/packages/docs/docs/interactive-with-schema.mdx
index 74b0066b26..371dc780d5 100644
--- a/packages/docs/docs/interactive-with-schema.mdx
+++ b/packages/docs/docs/interactive-with-schema.mdx
@@ -11,27 +11,18 @@ Wraps a React component so Remotion Studio can expose its props as timeline cont
Use it when you build a component that should behave like [`<Sequence>`](/docs/sequence), [`<Solid>`](/docs/solid) or [`<CanvasImage>`](/docs/canvasimage): The component appears in the timeline, can expose editable controls and can receive saved values from the Studio.
-## Example
+## Automatic wrapping example<AvailableFrom v="4.0.530" />
```tsx twoslash title="Circle.tsx"
import type React from 'react';
-import {
- Interactive,
- Sequence,
- type InteractiveBaseProps,
- type InteractiveTransformProps,
- type SequenceControls,
- type InteractivitySchema,
-} from 'remotion';
-
-type CircleProps = InteractiveBaseProps &
- InteractiveTransformProps & {
+import {Interactive, type InteractiveTransformProps, type InteractivitySchema} from 'remotion';
+
+type CircleProps = InteractiveTransformProps & {
readonly radius?: number;
readonly color?: string;
};
const circleSchema = {
- ...Interactive.baseSchema,
radius: {
type: 'number',
min: 1,
@@ -48,49 +39,29 @@ const circleSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const CircleInner: React.FC<
- CircleProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
- radius = 80,
- color = '#0b84ff',
- name,
- style,
- controls,
- ...sequenceProps
-}) => {
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- name={name ?? '<Circle>'}
- controls={controls}
- >
- <div
- style={{
- ...style,
- width: radius * 2,
- height: radius * 2,
- borderRadius: '50%',
- backgroundColor: color,
- }}
- />
- </Sequence>
- );
+const CircleInner: React.FC<CircleProps> = ({radius = 80, color = '#0b84ff', style}) => {
+ return (
+ <div
+ style={{
+ ...style,
+ width: radius * 2,
+ height: radius * 2,
+ borderRadius: '50%',
+ backgroundColor: color,
+ }}
+ />
+ );
};
export const Circle = Interactive.withSchema({
Component: CircleInner,
componentName: '<Circle>',
schema: circleSchema,
- supportsEffects: false,
+ wrapInSequence: true,
});
```
-The exported `Circle` component only accepts `CircleProps`. The `controls` prop is passed by `Interactive.withSchema()` to the inner component and should be forwarded unchanged to the [`<Sequence>`](/docs/sequence) that represents the component in the timeline. It also preserves the outer component's source location for Studio edits.
-
-With `<Sequence layout="none">`, the Studio discovers the rendered element automatically.
+The exported `Circle` component accepts `CircleProps` and the common timing props from [`<Sequence>`](/docs/sequence). The wrapper registers the component in the timeline and preserves its source location for Studio edits.
## API
@@ -104,34 +75,81 @@ Call `Interactive.withSchema()` with an options object.
The component to wrap.
-It must accept its public props plus `controls`.
+With automatic wrapping, it only needs to accept its own public props. It must not declare `controls` or any of the common timing props because the wrapper owns those props. When cropping is enabled, it must also accept a `style` prop and apply it to its visual root, and it must not declare the crop props itself. Without automatic wrapping, it must accept `controls`.
+
+### `componentName`
+
+The component name used by Studio and in validation messages. Automatic wrapping also uses it as the default timeline label.
+
+### `defaultDurationInFrames?`<AvailableFrom v="4.0.530" />
+
+Sets the default Sequence duration when automatic wrapping is enabled and no `durationInFrames` prop is passed.
+
+### `defaultSequenceName?`<AvailableFrom v="4.0.530" />
+
+Overrides the default timeline label when automatic wrapping is enabled. An explicit [`name`](/docs/sequence#name) prop still takes precedence.
### `controls`
The control state created by `Interactive.withSchema()`.
-Forward it to the `<Sequence>` that registers the component in the timeline.
+When manually wrapping the component, forward it to the `<Sequence>` that registers the component in the timeline. It is not passed to `Component` when `wrapInSequence` is enabled.
### `schema`
An [`InteractivitySchema`](/docs/interactivity-schema) that describes which props are editable in Remotion Studio.
-As a rule, include [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) in every schema passed to `Interactive.withSchema()` so standard timeline controls remain available.
+With automatic wrapping, [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) is added automatically. With `wrapInSequence: {cropping: true}`, [`Interactive.cropSchema`](/docs/interactive#interactivecropschema) is added as well.
-Use [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) for Sequence-like timeline props. Use [`Interactive.transformSchema`](/docs/interactive#interactivetransformschema) if the component accepts a `style` prop and should expose transform controls. Use [`Interactive.cropSchema`](/docs/interactive#interactivecropschema) with `InteractiveCropProps` to opt the component into crop controls.
+When manually wrapping the component, include [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) for Sequence-like timeline props. Use [`Interactive.transformSchema`](/docs/interactive#interactivetransformschema) if the component accepts a `style` prop and should expose transform controls. Use [`Interactive.cropSchema`](/docs/interactive#interactivecropschema) with `InteractiveCropProps` to opt the component into crop controls.
For reliable source updates, follow [Interactivity best practices](/docs/studio/interactivity-best-practices): Keep editable values inline, use hardcoded `interpolate()` keyframe arrays, use `translate`, `scale`, `rotate` and `opacity` directly, and avoid animated layout props or `transform` strings.
+### `wrapInSequence?`<AvailableFrom v="4.0.530" />
+
+Set to `true` to wrap `Component` in `<Sequence layout="none">`, add `Interactive.baseSchema` and expose the common timing props on the returned component.
+
+Default: `false`. Omit it when `Component` renders its own [`<Sequence>`](/docs/sequence), for example to configure premounting, effects, cropping that cannot be applied to the visual root, or custom timeline behavior.
+
+#### `cropping`
+
+Set `wrapInSequence` to `{cropping: true}` to additionally add `Interactive.cropSchema` and expose `cropLeft`, `cropRight`, `cropTop` and `cropBottom` on the returned component. Each value is a ratio from `0` to `1` of the corresponding width or height: `0` leaves the edge unchanged and `1` crops it fully.
+
+The wrapper converts these props to a CSS `clipPath` and merges it into the `style` passed to `Component`. While cropping is applied, this replaces an existing inline `style.clipPath`. The generated [`<Sequence>`](/docs/sequence) keeps `layout="none"`.
+
+```tsx twoslash title="Circle.tsx"
+import type React from 'react';
+import {Interactive, type InteractiveTransformProps} from 'remotion';
+
+const CircleInner: React.FC<InteractiveTransformProps> = ({style}) => <div style={style} />;
+const circleSchema = {};
+// ---cut---
+export const Circle = Interactive.withSchema({
+ Component: CircleInner,
+ componentName: '<Circle>',
+ schema: circleSchema,
+ wrapInSequence: {cropping: true},
+});
+```
+
+For cropping to be visible, `Component` must accept `style` and apply it to its visual root.
+
### `supportsEffects`
-Set to `true` if this component supports an `effects` prop. Otherwise, set it to `false`.
+Required when manually wrapping a component. Set to `true` if the component supports an `effects` prop. Otherwise, set it to `false`.
+
+Omit it when automatic wrapping is enabled. Components that support effects need to render their own `<Sequence>`.
### Return value
-Returns a component with the public props of `Component`.
+Returns a component with the public props of `Component`. With automatic wrapping, the common timing props from [`<Sequence>`](/docs/sequence) are also included. The cropping configuration additionally includes [`InteractiveCropProps`](/docs/interactive#interactivecropprops).
+
+### Ref forwarding<AvailableFrom v="4.0.530" />
+
+If `Component` accepts a ref, automatic wrapping preserves its ref type and forwards the ref directly to `Component`.
## Behavior
-During rendering, in the Player and in read-only Studio sessions, `Interactive.withSchema()` renders the component with the original props.
+During rendering, in the Player and in read-only Studio sessions, `Interactive.withSchema()` uses the original editable values. Automatic wrapping still applies timing, and the cropping configuration consumes the crop props and passes their computed result through `style`.
In editable Studio sessions, it reads the current prop values, applies timeline overrides and passes the merged props to the inner component.
diff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdx
index e82dde27a3..651a55b80c 100644
--- a/packages/docs/docs/sequence.mdx
+++ b/packages/docs/docs/sequence.mdx
@@ -316,7 +316,7 @@ You can give your sequence a name and it will be shown as the label of the seque
The control state created by [`Interactive.withSchema()`](/docs/interactive-with-schema).
-When [making a custom component interactive](/docs/studio/make-component-interactive), forward `controls` unchanged from the inner component to the `<Sequence>` that represents it in the timeline. Do not create this object manually.
+When [making a custom component interactive](/docs/studio/make-component-interactive) with a manually rendered `<Sequence>`, forward `controls` unchanged from the inner component. Do not create this object manually. With automatic wrapping, [`Interactive.withSchema()`](/docs/interactive-with-schema) handles this automatically.
### `layout?`
@@ -415,7 +415,7 @@ The eye icon in the Studio timeline toggles this prop and persists it to your so
## Adding a ref
-You can add a [React ref](https://react.dev/learn/manipulating-the-dom-with-refs) to an `<Sequence>` from version `v3.2.13` on. If you use TypeScript, you need to type it with `HTMLDivElement`:
+You can add a [React ref](https://react.dev/learn/manipulating-the-dom-with-refs) to a `<Sequence>` from version `v3.2.13` on. If you use TypeScript, you need to type it with `HTMLDivElement`:
```tsx twoslash
import {useRef} from 'react';
@@ -433,6 +433,10 @@ const MyComp = () => {
};
```
+Refs require the wrapper element created by `layout="absolute-fill"`. A `<Sequence layout="none">` rejects refs because it does not render a wrapper element.
+
+When [`Interactive.withSchema()`](/docs/interactive-with-schema) creates a layout-none Sequence automatically, a ref is forwarded to the inner component instead of the generated Sequence, if the inner component accepts one.
+
## Note for `@remotion/three`
A `<Sequence>` by default will return a `<div>` component which is not allowed inside a [`<ThreeCanvas>`](/docs/three-canvas).
diff --git a/packages/docs/docs/studio/make-component-interactive.mdx b/packages/docs/docs/studio/make-component-interactive.mdx
index dca75dd563..e82f1f4a66 100644
--- a/packages/docs/docs/studio/make-component-interactive.mdx
+++ b/packages/docs/docs/studio/make-component-interactive.mdx
@@ -1,7 +1,7 @@
---
image: /generated/articles-docs-studio-make-component-interactive.png
title: Make a component interactive
-crumb: "Remotion Studio"
+crumb: 'Remotion Studio'
---
# Make a component interactive<AvailableFrom v="4.0.479" />
@@ -11,36 +11,51 @@ Interactive components can be selected in the Remotion Studio timeline and can e
If you only need an editable HTML or SVG element, use [`Interactive`](/docs/interactive). For a custom component, wrap it with [`Interactive.withSchema()`](/docs/interactive-with-schema).
For code that remains editable after visual changes, follow [Interactivity best practices](/docs/studio/interactivity-best-practices).
-## Create a schema
+The automatic wrapping pattern used in this guide is available from <AvailableFrom v="4.0.530" inline />.
+
+## Create the component
-An [`InteractivitySchema`](/docs/interactivity-schema) describes which props the Studio may edit.
+The component only needs to render its content. It does not need to render a [`<Sequence>`](/docs/sequence) or accept internal control props.
+
+```tsx twoslash title="Badge.tsx"
+import type React from 'react';
+import type {InteractiveTransformProps} from 'remotion';
+
+type BadgeProps = InteractiveTransformProps & {
+ readonly children?: React.ReactNode;
+ readonly color?: string;
+ readonly padding?: number;
+};
-Use [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) for props inherited from [`<Sequence>`](/docs/sequence), such as [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`playbackRate`](/docs/sequence#playbackrate), [`loop`](/docs/sequence#loop), [`durationInFrames`](/docs/sequence#durationinframes), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).
+export const BadgeInner: 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>
+ );
+};
+```
-As a rule, include `Interactive.baseSchema` in every schema passed to `Interactive.withSchema()` so trimming, looping and visibility controls remain available. Forward all of these props to the `<Sequence>` your component renders.
+## Create a schema
-Use [`Interactive.transformSchema`](/docs/interactive#interactivetransformschema) if your component accepts a `style` prop and applies it to the rendered element.
+An [`InteractivitySchema`](/docs/interactivity-schema) describes which component props the Studio may edit.
-Use [`Interactive.cropSchema`](/docs/interactive#interactivecropschema) and `InteractiveCropProps` to opt a component into the crop controls inherited from an absolute-fill [`<Sequence>`](/docs/sequence).
+Use [`Interactive.transformSchema`](/docs/interactive#interactivetransformschema) if the component accepts a `style` prop and applies it to the rendered element.
```tsx twoslash title="Badge.tsx"
-import type React from 'react';
-import {
- Interactive,
- type InteractiveBaseProps,
- type InteractiveTransformProps,
- type InteractivitySchema,
-} from 'remotion';
-
-type BadgeProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly children?: React.ReactNode;
- readonly color?: string;
- readonly padding?: number;
- };
+import {Interactive, type InteractivitySchema} from 'remotion';
const badgeSchema = {
- ...Interactive.baseSchema,
color: {
type: 'color',
default: '#0b84ff',
@@ -58,127 +73,55 @@ const badgeSchema = {
} as const satisfies InteractivitySchema;
```
-## Caption fields<AvailableFrom v="4.0.500" />
+`Interactive.baseSchema` is added automatically when `wrapInSequence` is enabled.
-Add a `captions` field when a custom component accepts [`Caption[]`](/docs/captions/caption) data:
+### Caption fields<AvailableFrom v="4.0.500" />
+
+Add [`Interactive.captionsSchema`](/docs/interactive#interactivecaptionsschema) when the component accepts [`Caption[]`](/docs/captions/caption) data:
```ts twoslash title="Captions.tsx"
import {Interactive, type InteractivitySchema} from 'remotion';
const captionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
} as const satisfies InteractivitySchema;
```
Studio can edit caption text when the prop is a direct JSX array literal, such as `captions={[...]}`. Variables, imports, computed expressions, and `satisfies` expressions are read-only.
-## Forward `controls`
-
-The inner component receives a `controls` prop from `Interactive.withSchema()`.
+## Make the component interactive<AvailableFrom v="4.0.530" />
-Forward it unchanged to the [`<Sequence>`](/docs/sequence) that represents your component in the timeline. Forwarding it also allows the Studio to associate the timeline item with the outer component's source location.
+Pass `wrapInSequence: true` to add the timeline registration and timing behavior automatically:
```tsx twoslash title="Badge.tsx"
import type React from 'react';
-import {
- Interactive,
- Sequence,
- type InteractiveBaseProps,
- type InteractiveTransformProps,
- type InteractivitySchema,
- type SequenceControls,
-} from 'remotion';
-
-type BadgeProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly children?: React.ReactNode;
- readonly color?: string;
- readonly padding?: number;
- };
+import {Interactive, type InteractiveTransformProps, type InteractivitySchema} from 'remotion';
-const badgeSchema = {
- ...Interactive.baseSchema,
- color: {
- type: 'color',
- default: '#0b84ff',
- description: 'Color',
- },
- padding: {
- type: 'number',
- min: 0,
- step: 1,
- default: 16,
- description: 'Padding',
- hiddenFromList: false,
- },
- ...Interactive.transformSchema,
-} as const satisfies InteractivitySchema;
-// ---cut---
-const BadgeInner: React.FC<
- BadgeProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
- children,
- color = '#0b84ff',
- padding = 16,
- style,
- name,
- controls,
- ...sequenceProps
-}) => {
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- name={name ?? '<Badge>'}
- controls={controls}
- >
- <div
- style={{
- ...style,
- display: 'inline-flex',
- borderRadius: 999,
- backgroundColor: color,
- color: 'white',
- fontWeight: 700,
- padding,
- }}
- >
- {children}
- </div>
- </Sequence>
- );
+type BadgeProps = InteractiveTransformProps & {
+ readonly children?: React.ReactNode;
+ readonly color?: string;
+ readonly padding?: number;
};
-```
-
-The exported component should not expose `controls` as a public prop.
-With `<Sequence layout="none">`, the Studio discovers the rendered element automatically.
-
-## Wrap the component
-
-```tsx twoslash title="Badge.tsx"
-import type React from 'react';
-import {
- Interactive,
- Sequence,
- type InteractiveBaseProps,
- type InteractiveTransformProps,
- type InteractivitySchema,
- type SequenceControls,
-} from 'remotion';
-
-type BadgeProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly children?: React.ReactNode;
- readonly color?: string;
- readonly padding?: number;
- };
+const BadgeInner: 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>
+ );
+};
const badgeSchema = {
- ...Interactive.baseSchema,
color: {
type: 'color',
default: '#0b84ff',
@@ -195,51 +138,20 @@ const badgeSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const BadgeInner: React.FC<
- BadgeProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
- children,
- color = '#0b84ff',
- padding = 16,
- style,
- name,
- controls,
- ...sequenceProps
-}) => {
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- name={name ?? '<Badge>'}
- controls={controls}
- >
- <div
- style={{
- ...style,
- display: 'inline-flex',
- borderRadius: 999,
- backgroundColor: color,
- color: 'white',
- fontWeight: 700,
- padding,
- }}
- >
- {children}
- </div>
- </Sequence>
- );
-};
-// ---cut---
export const Badge = Interactive.withSchema({
Component: BadgeInner,
componentName: '<Badge>',
schema: badgeSchema,
- supportsEffects: false,
+ wrapInSequence: true,
});
```
+The returned component accepts the component's own props and the common timing props from [`<Sequence>`](/docs/sequence), including `from`, `durationInFrames`, `trimBefore`, `playbackRate`, `loop`, `freeze`, `hidden`, `name` and `showInTimeline`.
+
+The wrapper uses `<Sequence layout="none">`, so Studio discovers the rendered element automatically.
+
+If the inner component supports a React ref, the returned component forwards refs directly to it.
+
## Use the component
```tsx title="MyComp.tsx"
@@ -249,12 +161,7 @@ import {Badge} from './Badge';
export const MyComp = () => {
return (
<AbsoluteFill>
- <Badge
- from={30}
- durationInFrames={90}
- color="#ff5c7a"
- style={{translate: '120px 80px'}}
- >
+ <Badge from={30} durationInFrames={90} color="#ff5c7a" style={{translate: '120px 80px'}}>
Sale
</Badge>
</AbsoluteFill>
@@ -264,23 +171,36 @@ export const MyComp = () => {
The component now has a timeline row, inherits the common `<Sequence>` props and exposes `color`, `padding` and transform controls in the Studio.
-## Choosing schema fragments
+## Enable cropping<AvailableFrom v="4.0.530" />
-### `Interactive.baseSchema`
+If the component accepts a `style` prop and applies it to its visual root, pass `{cropping: true}` instead of `true`:
-Use it when the component renders a `<Sequence>` internally.
+```tsx title="Badge.tsx"
+export const Badge = Interactive.withSchema({
+ Component: BadgeInner,
+ componentName: '<Badge>',
+ schema: badgeSchema,
+ wrapInSequence: {cropping: true},
+});
+```
-### `Interactive.transformSchema`
+This adds [`Interactive.cropSchema`](/docs/interactive#interactivecropschema) and exposes `cropLeft`, `cropRight`, `cropTop` and `cropBottom` on the returned component. Each value is a ratio from `0` to `1` of the corresponding width or height.
+
+```tsx title="MyComp.tsx"
+<Badge cropLeft={0.2} cropBottom={0.1}>
+ Sale
+</Badge>
+```
-Use it when the component accepts a `style` prop and applies it to the rendered element.
+The generated `<Sequence>` still uses `layout="none"`. The wrapper applies cropping by merging a CSS `clipPath` into the `style` passed to the component. While cropping is applied, this replaces an existing inline `style.clipPath`.
-### `Interactive.cropSchema`<AvailableFrom v="4.0.500" />
+## Manual wrapping
-Use it with `InteractiveCropProps` when the component applies crop props to its rendered element or forwards them to an absolute-fill [`<Sequence>`](/docs/sequence).
+Omit `wrapInSequence` when the component needs to render and configure its own `<Sequence>`, for example to support premounting, effects, cropping that cannot be applied to the visual root, or custom timeline behavior.
-### `Interactive.premountSchema`
+In this advanced form, include [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema), accept the injected [`SequenceControls`](/docs/sequence#controls) prop and forward it unchanged to the component's `<Sequence>`. Also forward every prop represented by `Interactive.baseSchema` to that Sequence, and set `supportsEffects` to `true` or `false` in the `Interactive.withSchema()` options.
-Use it when the component forwards `premountFor` and `postmountFor` to a `<Sequence>`.
+For premounting, also include [`Interactive.premountSchema`](/docs/interactive#interactivepremountschema), accept [`InteractivePremountProps`](/docs/interactive#interactivepremountprops) and forward those props to the Sequence. For cropping on an absolute-fill Sequence, include [`Interactive.cropSchema`](/docs/interactive#interactivecropschema), accept [`InteractiveCropProps`](/docs/interactive#interactivecropprops) and forward the crop props to the Sequence.
## See also
diff --git a/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx b/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx
index 94836b0954..305fd890e7 100644
--- a/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx
+++ b/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx
@@ -3,25 +3,20 @@ import {useWindowedAudioData, visualizeAudio} from '@remotion/media-utils';
import React from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type MirroredAudioSpectrumProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly audioSrc?: string;
- readonly barColor?: string;
- readonly numberOfBars?: number;
- readonly sensitivity?: number;
- };
+type MirroredAudioSpectrumProps = InteractiveTransformProps & {
+ readonly audioSrc?: string;
+ readonly barColor?: string;
+ readonly numberOfBars?: number;
+ readonly sensitivity?: number;
+};
const mirroredAudioSpectrumSchema = {
- ...Interactive.baseSchema,
audioSrc: {
type: 'asset',
assetType: 'audio',
@@ -125,39 +120,28 @@ const MirroredAudioSpectrumContent: React.FC<{
);
};
-const MirroredAudioSpectrumInner: React.FC<
- MirroredAudioSpectrumProps & {readonly controls: SequenceControls | undefined}
-> = ({
+const MirroredAudioSpectrumInner: React.FC<MirroredAudioSpectrumProps> = ({
audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
barColor = '#2563eb',
- controls,
- name,
numberOfBars = 65,
sensitivity = 1.5,
style,
- ...sequenceProps
}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Mirrored audio spectrum'}
- >
- <MirroredAudioSpectrumContent
- audioSrc={audioSrc}
- barColor={barColor}
- numberOfBars={numberOfBars}
- sensitivity={sensitivity}
- style={style}
- />
- </Sequence>
+ <MirroredAudioSpectrumContent
+ audioSrc={audioSrc}
+ barColor={barColor}
+ numberOfBars={numberOfBars}
+ sensitivity={sensitivity}
+ style={style}
+ />
);
};
export const MirroredAudioSpectrum = Interactive.withSchema({
Component: MirroredAudioSpectrumInner,
componentName: '<MirroredAudioSpectrum>',
+ defaultSequenceName: 'Mirrored audio spectrum',
schema: mirroredAudioSpectrumSchema,
- supportsEffects: false,
-}) as React.FC<MirroredAudioSpectrumProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx b/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx
index 9fdaf67414..d9a2f98e89 100644
--- a/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx
+++ b/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx
@@ -7,26 +7,21 @@ import {
import React from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type AudioOscilloscopeProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly amplitude?: number;
- readonly audioSrc?: string;
- readonly lineColor?: string;
- readonly lineWidth?: number;
- readonly windowInSeconds?: number;
- };
+type AudioOscilloscopeProps = InteractiveTransformProps & {
+ readonly amplitude?: number;
+ readonly audioSrc?: string;
+ readonly lineColor?: string;
+ readonly lineWidth?: number;
+ readonly windowInSeconds?: number;
+};
const audioOscilloscopeSchema = {
- ...Interactive.baseSchema,
audioSrc: {
type: 'asset',
assetType: 'audio',
@@ -141,41 +136,30 @@ const AudioOscilloscopeContent: React.FC<{
);
};
-const AudioOscilloscopeInner: React.FC<
- AudioOscilloscopeProps & {readonly controls: SequenceControls | undefined}
-> = ({
+const AudioOscilloscopeInner: React.FC<AudioOscilloscopeProps> = ({
amplitude = 2,
audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- controls,
lineColor = '#2563eb',
lineWidth = 6,
- name,
style,
windowInSeconds = 0.35,
- ...sequenceProps
}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Audio oscilloscope'}
- >
- <AudioOscilloscopeContent
- amplitude={amplitude}
- audioSrc={audioSrc}
- lineColor={lineColor}
- lineWidth={lineWidth}
- style={style}
- windowInSeconds={windowInSeconds}
- />
- </Sequence>
+ <AudioOscilloscopeContent
+ amplitude={amplitude}
+ audioSrc={audioSrc}
+ lineColor={lineColor}
+ lineWidth={lineWidth}
+ style={style}
+ windowInSeconds={windowInSeconds}
+ />
);
};
export const AudioOscilloscope = Interactive.withSchema({
Component: AudioOscilloscopeInner,
componentName: '<AudioOscilloscope>',
+ defaultSequenceName: 'Audio oscilloscope',
schema: audioOscilloscopeSchema,
- supportsEffects: false,
-}) as React.FC<AudioOscilloscopeProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx b/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx
index 4ef3e8892a..f8eb602f93 100644
--- a/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx
+++ b/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx
@@ -3,27 +3,22 @@ import {getWaveformPortion, useWindowedAudioData} from '@remotion/media-utils';
import React, {useId, useMemo} from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type AudioWaveformProgressProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly amplitude?: number;
- readonly audioSrc?: string;
- readonly barGap?: number;
- readonly numberOfBars?: number;
- readonly playedColor?: string;
- readonly unplayedColor?: string;
- };
+type AudioWaveformProgressProps = InteractiveTransformProps & {
+ readonly amplitude?: number;
+ readonly audioSrc?: string;
+ readonly barGap?: number;
+ readonly numberOfBars?: number;
+ readonly playedColor?: string;
+ readonly unplayedColor?: string;
+};
const audioWaveformProgressSchema = {
- ...Interactive.baseSchema,
audioSrc: {
type: 'asset',
assetType: 'audio',
@@ -77,7 +72,6 @@ const AudioWaveformProgressContent: React.FC<{
readonly amplitude: number;
readonly audioSrc: string;
readonly barGap: number;
- readonly durationInFrames: number;
readonly numberOfBars: number;
readonly playedColor: string;
readonly unplayedColor: string;
@@ -85,13 +79,12 @@ const AudioWaveformProgressContent: React.FC<{
amplitude,
audioSrc,
barGap,
- durationInFrames,
numberOfBars,
playedColor,
unplayedColor,
}) => {
const frame = useCurrentFrame();
- const {fps} = useVideoConfig();
+ const {durationInFrames, fps} = useVideoConfig();
const durationInSeconds = durationInFrames / fps;
const {audioData, dataOffsetInSeconds} = useWindowedAudioData({
fps,
@@ -167,57 +160,44 @@ const AudioWaveformProgressContent: React.FC<{
);
};
-const AudioWaveformProgressInner: React.FC<
- AudioWaveformProgressProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const AudioWaveformProgressInner: React.FC<AudioWaveformProgressProps> = ({
amplitude = 1,
audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
barGap = 5,
- controls,
- durationInFrames = 271,
- name,
numberOfBars = 64,
playedColor = '#2563eb',
style,
unplayedColor = '#cbd5e1',
- ...sequenceProps
}) => {
+ const {durationInFrames} = useVideoConfig();
+
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- durationInFrames={durationInFrames}
- name={name ?? 'Audio waveform progress'}
+ <div
+ style={{
+ boxSizing: 'border-box',
+ height: 300,
+ width: 900,
+ ...style,
+ }}
>
- <div
- style={{
- boxSizing: 'border-box',
- height: 300,
- width: 900,
- ...style,
- }}
- >
- <AudioWaveformProgressContent
- key={`${audioSrc}-${durationInFrames}`}
- amplitude={amplitude}
- audioSrc={audioSrc}
- barGap={barGap}
- durationInFrames={durationInFrames}
- numberOfBars={numberOfBars}
- playedColor={playedColor}
- unplayedColor={unplayedColor}
- />
- </div>
- </Sequence>
+ <AudioWaveformProgressContent
+ key={`${audioSrc}-${durationInFrames}`}
+ amplitude={amplitude}
+ audioSrc={audioSrc}
+ barGap={barGap}
+ numberOfBars={numberOfBars}
+ playedColor={playedColor}
+ unplayedColor={unplayedColor}
+ />
+ </div>
);
};
export const AudioWaveformProgress = Interactive.withSchema({
Component: AudioWaveformProgressInner,
componentName: '<AudioWaveformProgress>',
+ defaultDurationInFrames: 271,
+ defaultSequenceName: 'Audio waveform progress',
schema: audioWaveformProgressSchema,
- supportsEffects: false,
-}) as React.FC<AudioWaveformProgressProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/captions/basic-captions/basic-captions.tsx b/packages/docs/elements/captions/basic-captions/basic-captions.tsx
index faf37d42c3..9c7bedb33d 100644
--- a/packages/docs/elements/captions/basic-captions/basic-captions.tsx
+++ b/packages/docs/elements/captions/basic-captions/basic-captions.tsx
@@ -3,21 +3,16 @@ import {createTikTokStyleCaptions} from '@remotion/captions';
import React, {useMemo} from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type BasicCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
+type BasicCaptionsProps = InteractiveTransformProps &
Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
- readonly playbackRate?: number;
readonly combineTokensWithinMilliseconds?: number;
};
@@ -26,7 +21,6 @@ const defaultWidth = 900;
const defaultHeight = 220;
const basicCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -57,15 +51,8 @@ const basicCaptionsSchema = {
const BasicCaptionsContent: React.FC<{
readonly captions: Caption[];
- readonly playbackRate: number;
- readonly trimBefore: number;
readonly combineTokensWithinMilliseconds: number;
-}> = ({
- captions,
- playbackRate,
- trimBefore,
- combineTokensWithinMilliseconds,
-}) => {
+}> = ({captions, combineTokensWithinMilliseconds}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const pages = useMemo(
@@ -76,9 +63,7 @@ const BasicCaptionsContent: React.FC<{
}).pages,
[captions, combineTokensWithinMilliseconds],
);
- // The Sequence frame already includes trimBefore; only elapsed frames speed up.
- const currentTimeMs =
- ((trimBefore + (frame - trimBefore) * playbackRate) / fps) * 1000;
+ const currentTimeMs = (frame / fps) * 1000;
const page = pages.find(
(candidate) =>
currentTimeMs >= candidate.startMs &&
@@ -113,49 +98,30 @@ const BasicCaptionsContent: React.FC<{
);
};
-const BasicCaptionsInner: React.FC<
- BasicCaptionsProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const BasicCaptionsInner: React.FC<BasicCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
height = defaultHeight,
- name,
- playbackRate = 1,
style,
- trimBefore,
width = defaultWidth,
- ...interactiveProps
}) => {
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<BasicCaptions>'}
- trimBefore={trimBefore}
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+ marginInline: 'auto',
+ width,
+ height,
+ ...style,
+ }}
>
- <div
- style={{
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- marginInline: 'auto',
- width,
- height,
- ...style,
- }}
- >
- <BasicCaptionsContent
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
+ <BasicCaptionsContent
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ />
+ </div>
);
};
@@ -163,7 +129,7 @@ const BasicCaptionsLayer = Interactive.withSchema({
Component: BasicCaptionsInner,
componentName: '<BasicCaptions>',
schema: basicCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<BasicCaptionsProps>;
+ wrapInSequence: true,
+});
export const BasicCaptions = BasicCaptionsLayer;
diff --git a/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx b/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx
index 4f1ea0b326..62ad44423e 100644
--- a/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx
+++ b/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx
@@ -13,22 +13,17 @@ import {
cancelRender,
Interactive,
interpolate,
- Sequence,
spring,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type MovingPillCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
+type MovingPillCaptionsProps = InteractiveTransformProps &
Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
- readonly playbackRate?: number;
readonly combineTokensWithinMilliseconds?: number;
};
@@ -45,7 +40,6 @@ const defaultWidth = 682;
const defaultHeight = 252;
const movingPillCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -330,15 +324,11 @@ const MovingPillCaptionsContent: React.FC<{
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds: number;
readonly fontLoaded: boolean;
- readonly playbackRate: number;
- readonly trimBefore: number;
}> = ({
captionAreaWidth,
captions,
combineTokensWithinMilliseconds,
fontLoaded,
- playbackRate,
- trimBefore,
}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
@@ -350,8 +340,7 @@ const MovingPillCaptionsContent: React.FC<{
}).pages,
[captions, combineTokensWithinMilliseconds],
);
- const currentTimeMs =
- ((trimBefore + (frame - trimBefore) * playbackRate) / fps) * 1000;
+ const currentTimeMs = (frame / fps) * 1000;
const activePageIndex = getActivePageIndex(pages, currentTimeMs);
const page = pages[activePageIndex];
@@ -371,21 +360,12 @@ const MovingPillCaptionsContent: React.FC<{
);
};
-const MovingPillCaptionsInner: React.FC<
- MovingPillCaptionsProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const MovingPillCaptionsInner: React.FC<MovingPillCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
height = defaultHeight,
- name,
- playbackRate = 1,
style,
- trimBefore,
width = defaultWidth,
- ...interactiveProps
}) => {
const [fontLoaded, setFontLoaded] = useState(false);
@@ -400,31 +380,21 @@ const MovingPillCaptionsInner: React.FC<
}, []);
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<MovingPillCaptions>'}
- trimBefore={trimBefore}
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <MovingPillCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
+ <MovingPillCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ />
+ </div>
);
};
@@ -432,7 +402,7 @@ const MovingPillCaptionsLayer = Interactive.withSchema({
Component: MovingPillCaptionsInner,
componentName: '<MovingPillCaptions>',
schema: movingPillCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<MovingPillCaptionsProps>;
+ wrapInSequence: true,
+});
export const MovingPillCaptions = MovingPillCaptionsLayer;
diff --git a/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx b/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx
index c3804d5388..58b604c572 100644
--- a/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx
+++ b/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx
@@ -7,22 +7,17 @@ import {
cancelRender,
Interactive,
interpolate,
- Sequence,
spring,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type PoppingWordCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
+type PoppingWordCaptionsProps = InteractiveTransformProps &
Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
- readonly playbackRate?: number;
readonly combineTokensWithinMilliseconds?: number;
};
@@ -36,7 +31,6 @@ const defaultWidth = 682;
const defaultHeight = 252;
const poppingWordCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -236,15 +230,11 @@ const PoppingWordCaptionsContent: React.FC<{
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds: number;
readonly fontLoaded: boolean;
- readonly playbackRate: number;
- readonly trimBefore: number;
}> = ({
captionAreaWidth,
captions,
combineTokensWithinMilliseconds,
fontLoaded,
- playbackRate,
- trimBefore,
}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
@@ -256,8 +246,7 @@ const PoppingWordCaptionsContent: React.FC<{
}).pages,
[captions, combineTokensWithinMilliseconds],
);
- const currentTimeMs =
- ((trimBefore + (frame - trimBefore) * playbackRate) / fps) * 1000;
+ const currentTimeMs = (frame / fps) * 1000;
const activePageIndex = getActivePageIndex(pages, currentTimeMs);
const page = pages[activePageIndex];
@@ -277,21 +266,12 @@ const PoppingWordCaptionsContent: React.FC<{
);
};
-const PoppingWordCaptionsInner: React.FC<
- PoppingWordCaptionsProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const PoppingWordCaptionsInner: React.FC<PoppingWordCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
height = defaultHeight,
- name,
- playbackRate = 1,
style,
- trimBefore,
width = defaultWidth,
- ...interactiveProps
}) => {
const [fontLoaded, setFontLoaded] = useState(false);
@@ -306,31 +286,21 @@ const PoppingWordCaptionsInner: React.FC<
}, []);
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<PoppingWordCaptions>'}
- trimBefore={trimBefore}
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <PoppingWordCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
+ <PoppingWordCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ />
+ </div>
);
};
@@ -338,7 +308,7 @@ const PoppingWordCaptionsLayer = Interactive.withSchema({
Component: PoppingWordCaptionsInner,
componentName: '<PoppingWordCaptions>',
schema: poppingWordCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<PoppingWordCaptionsProps>;
+ wrapInSequence: true,
+});
export const PoppingWordCaptions = PoppingWordCaptionsLayer;
diff --git a/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx b/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
index 2fc42e960e..7f24061762 100644
--- a/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
+++ b/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
@@ -7,21 +7,16 @@ import React, {useEffect, useMemo, useState} from 'react';
import {
cancelRender,
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type RoundedCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
+type RoundedCaptionsProps = InteractiveTransformProps &
Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
- readonly playbackRate: number | null;
readonly combineTokensWithinMilliseconds: number | null;
};
@@ -35,7 +30,6 @@ const horizontalPadding = 22;
const borderRadius = 20;
const roundedCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -71,16 +65,12 @@ const {fontFamily, waitUntilDone} = loadFont('normal', {
const RoundedCaptionsContent: React.FC<{
readonly captions: Caption[];
- readonly playbackRate: number;
- readonly trimBefore: number;
readonly combineTokensWithinMilliseconds: number;
readonly fontLoaded: boolean;
readonly width: number;
readonly height: number;
}> = ({
captions,
- playbackRate,
- trimBefore,
combineTokensWithinMilliseconds,
fontLoaded,
width,
@@ -96,9 +86,7 @@ const RoundedCaptionsContent: React.FC<{
}).pages,
[captions, combineTokensWithinMilliseconds],
);
- // The Sequence frame already includes trimBefore; only elapsed frames speed up.
- const currentTimeMs =
- ((trimBefore + (frame - trimBefore) * playbackRate) / fps) * 1000;
+ const currentTimeMs = (frame / fps) * 1000;
const page = pages.find(
(candidate) =>
currentTimeMs >= candidate.startMs &&
@@ -205,21 +193,12 @@ const RoundedCaptionsContent: React.FC<{
);
};
-const RoundedCaptionsInner: React.FC<
- RoundedCaptionsProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const RoundedCaptionsInner: React.FC<RoundedCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds,
- controls,
height = defaultHeight,
- name,
- playbackRate,
style,
- trimBefore,
width = defaultWidth,
- ...interactiveProps
}) => {
const [fontLoaded, setFontLoaded] = useState(false);
@@ -230,38 +209,28 @@ const RoundedCaptionsInner: React.FC<
}, []);
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<RoundedCaptions>'}
- trimBefore={trimBefore}
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+ marginInline: 'auto',
+ width,
+ height,
+ ...style,
+ }}
>
- <div
- style={{
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- marginInline: 'auto',
- width,
- height,
- ...style,
- }}
- >
- <RoundedCaptionsContent
- captions={captions}
- combineTokensWithinMilliseconds={
- combineTokensWithinMilliseconds ??
- defaultCombineTokensWithinMilliseconds
- }
- fontLoaded={fontLoaded}
- playbackRate={playbackRate ?? 1}
- trimBefore={trimBefore ?? 0}
- width={width}
- height={height}
- />
- </div>
- </Sequence>
+ <RoundedCaptionsContent
+ captions={captions}
+ combineTokensWithinMilliseconds={
+ combineTokensWithinMilliseconds ??
+ defaultCombineTokensWithinMilliseconds
+ }
+ fontLoaded={fontLoaded}
+ width={width}
+ height={height}
+ />
+ </div>
);
};
@@ -269,5 +238,5 @@ export const RoundedCaptions = Interactive.withSchema({
Component: RoundedCaptionsInner,
componentName: '<RoundedCaptions>',
schema: roundedCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<RoundedCaptionsProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx b/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx
index df455809ca..e35c09a21d 100644
--- a/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx
+++ b/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx
@@ -6,21 +6,16 @@ import React, {useEffect, useMemo, useState} from 'react';
import {
cancelRender,
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type WordHighlightCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
+type WordHighlightCaptionsProps = InteractiveTransformProps &
Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
- readonly playbackRate?: number;
readonly combineTokensWithinMilliseconds?: number;
};
@@ -33,7 +28,6 @@ const defaultWidth = 682;
const defaultHeight = 252;
const wordHighlightCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -195,15 +189,11 @@ const WordHighlightCaptionsContent: React.FC<{
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds: number;
readonly fontLoaded: boolean;
- readonly playbackRate: number;
- readonly trimBefore: number;
}> = ({
captionAreaWidth,
captions,
combineTokensWithinMilliseconds,
fontLoaded,
- playbackRate,
- trimBefore,
}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
@@ -215,8 +205,7 @@ const WordHighlightCaptionsContent: React.FC<{
}).pages,
[captions, combineTokensWithinMilliseconds],
);
- const currentTimeMs =
- ((trimBefore + (frame - trimBefore) * playbackRate) / fps) * 1000;
+ const currentTimeMs = (frame / fps) * 1000;
const activePageIndex = getActivePageIndex(pages, currentTimeMs);
const page = pages[activePageIndex];
@@ -235,21 +224,12 @@ const WordHighlightCaptionsContent: React.FC<{
);
};
-const WordHighlightCaptionsInner: React.FC<
- WordHighlightCaptionsProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const WordHighlightCaptionsInner: React.FC<WordHighlightCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
height = defaultHeight,
- name,
- playbackRate = 1,
style,
- trimBefore,
width = defaultWidth,
- ...interactiveProps
}) => {
const [fontLoaded, setFontLoaded] = useState(false);
@@ -264,31 +244,21 @@ const WordHighlightCaptionsInner: React.FC<
}, []);
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<WordHighlightCaptions>'}
- trimBefore={trimBefore}
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <WordHighlightCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
+ <WordHighlightCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ />
+ </div>
);
};
@@ -296,7 +266,7 @@ const WordHighlightCaptionsLayer = Interactive.withSchema({
Component: WordHighlightCaptionsInner,
componentName: '<WordHighlightCaptions>',
schema: wordHighlightCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<WordHighlightCaptionsProps>;
+ wrapInSequence: true,
+});
export const WordHighlightCaptions = WordHighlightCaptionsLayer;
diff --git a/packages/docs/elements/commerce/product-collection/product-collection.tsx b/packages/docs/elements/commerce/product-collection/product-collection.tsx
index 43130f9e91..96b7f45c3c 100644
--- a/packages/docs/elements/commerce/product-collection/product-collection.tsx
+++ b/packages/docs/elements/commerce/product-collection/product-collection.tsx
@@ -4,13 +4,10 @@ import {
Easing,
Img,
Interactive,
- Sequence,
interpolate,
useCurrentFrame,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
loadFont('normal', {
@@ -20,16 +17,14 @@ loadFont('normal', {
export const productCollectionDurationInFrames = 150;
-type ProductCardProps = InteractiveBaseProps &
- Omit<InteractiveTransformProps, 'style'> & {
- readonly count: number;
- readonly index: number;
- readonly label: string;
- readonly style: React.CSSProperties | null;
- };
+type ProductCardProps = Omit<InteractiveTransformProps, 'style'> & {
+ readonly count: number;
+ readonly index: number;
+ readonly label: string;
+ readonly style: React.CSSProperties | null;
+};
const productCardSchema = {
- ...Interactive.baseSchema,
label: {
type: 'text-content',
default: 'A',
@@ -40,9 +35,12 @@ const productCardSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const ProductCardInner: React.FC<
- ProductCardProps & {readonly controls: SequenceControls | undefined}
-> = ({controls, count, index, label, name, style, ...sequenceProps}) => {
+const ProductCardInner: React.FC<ProductCardProps> = ({
+ count,
+ index,
+ label,
+ style,
+}) => {
const frame = useCurrentFrame();
const lastProductIndex = Math.max(0, count - 1);
const rawScrollPosition = interpolate(
@@ -100,82 +98,75 @@ const ProductCardInner: React.FC<
});
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? '<ProductCard>'}
+ <div
+ style={{
+ height: 560,
+ left: 300,
+ top: 40,
+ opacity: visibility * entryProgress,
+ position: 'absolute',
+ rotate: `${rotation}deg`,
+ scale: cardScale * (0.86 + entryProgress * 0.14),
+ transform: 'perspective(100px)',
+ translate: `${x}px ${y}px`,
+ width: 300,
+ willChange: 'transform, opacity',
+ zIndex: 100 - Math.round(distanceFromCenter * 20),
+ }}
>
<div
style={{
- height: 560,
- left: 300,
- top: 40,
- opacity: visibility * entryProgress,
- position: 'absolute',
- rotate: `${rotation}deg`,
- scale: cardScale * (0.86 + entryProgress * 0.14),
- transform: 'perspective(100px)',
- translate: `${x}px ${y}px`,
- width: 300,
- willChange: 'transform, opacity',
- zIndex: 100 - Math.round(distanceFromCenter * 20),
+ ...style,
+ backgroundColor: '#ffffff',
+ borderRadius: 6,
+ boxShadow: '0 2px 6px rgba(29, 29, 25, 0.12)',
+ boxSizing: 'border-box',
+ color: '#1d1d19',
+ display: 'flex',
+ flexDirection: 'column',
+ height: '100%',
+ overflow: 'hidden',
+ width: '100%',
}}
>
- <div
+ <Interactive.Div
+ name="Card label"
style={{
- ...style,
- backgroundColor: '#ffffff',
- borderRadius: 6,
- boxShadow: '0 2px 6px rgba(29, 29, 25, 0.12)',
- boxSizing: 'border-box',
- color: '#1d1d19',
+ alignItems: 'center',
+ color: '#ffffff',
display: 'flex',
- flexDirection: 'column',
+ fontFamily: 'sans-serif',
+ fontSize: 160,
+ fontWeight: 900,
height: '100%',
+ justifyContent: 'center',
+ letterSpacing: -8,
overflow: 'hidden',
- width: '100%',
+ position: 'relative',
+ textShadow: '0 4px 30px rgba(0, 0, 0, 0.55)',
}}
>
- <Interactive.Div
- name="Card label"
+ <Img
+ alt=""
+ name="Card background"
+ showInTimeline={false}
+ src={
+ index === 1
+ ? 'https://remotion.media/transition-bg-pink.jpg'
+ : 'https://remotion.media/transition-bg-blue.jpg'
+ }
style={{
- alignItems: 'center',
- color: '#ffffff',
- display: 'flex',
- fontFamily: 'sans-serif',
- fontSize: 160,
- fontWeight: 900,
+ filter: index === 2 ? 'hue-rotate(-65deg)' : 'none',
height: '100%',
- justifyContent: 'center',
- letterSpacing: -8,
- overflow: 'hidden',
- position: 'relative',
- textShadow: '0 4px 30px rgba(0, 0, 0, 0.55)',
+ objectFit: 'cover',
+ position: 'absolute',
+ width: '100%',
}}
- >
- <Img
- alt=""
- name="Card background"
- showInTimeline={false}
- src={
- index === 1
- ? 'https://remotion.media/transition-bg-pink.jpg'
- : 'https://remotion.media/transition-bg-blue.jpg'
- }
- style={{
- filter: index === 2 ? 'hue-rotate(-65deg)' : 'none',
- height: '100%',
- objectFit: 'cover',
- position: 'absolute',
- width: '100%',
- }}
- />
- <div style={{position: 'relative'}}>{label}</div>
- </Interactive.Div>
- </div>
+ />
+ <div style={{position: 'relative'}}>{label}</div>
+ </Interactive.Div>
</div>
- </Sequence>
+ </div>
);
};
@@ -183,8 +174,8 @@ const ProductCard = Interactive.withSchema({
Component: ProductCardInner,
componentName: '<ProductCard>',
schema: productCardSchema,
- supportsEffects: false,
-}) as React.FC<ProductCardProps>;
+ wrapInSequence: true,
+});
export const ProductCollection = () => {
const frame = useCurrentFrame();
diff --git a/packages/docs/elements/guidelines.mdx b/packages/docs/elements/guidelines.mdx
index fb824fa676..99e3279eb8 100644
--- a/packages/docs/elements/guidelines.mdx
+++ b/packages/docs/elements/guidelines.mdx
@@ -48,18 +48,23 @@ Use `installationMode: 'component-owned-sequence'` when Studio interactivity doe
- Canvas-based Elements where individual outlines cannot be passed to Studio
- Single-image overlays where the image itself cannot be edited
-Wrap the exported component with [`Interactive.withSchema()`](/docs/interactive-with-schema). The user gets one timeline layer that they can move on the canvas and trim in the timeline. The implementation does not appear as separate editable layers.
+Wrap the exported component with [`Interactive.withSchema()`](/docs/interactive-with-schema) and set `wrapInSequence: true`. The user gets one timeline layer that they can trim. To make it movable on the canvas, include [`Interactive.transformSchema`](/docs/interactive#interactivetransformschema) and apply the `style` prop to the visual root. The implementation does not appear as separate editable layers.
-Export the schema-enabled component directly and wire up the common props:
+Use `defaultDurationInFrames` to preserve a component-owned default duration and `defaultSequenceName` when the friendly default timeline label should differ from `componentName`.
-- Add [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) to every `Interactive.withSchema()` schema and pass `controls` unchanged to the component's `<Sequence>`.
-- Pass `from`, `durationInFrames`, `trimBefore`, `playbackRate`, `loop`, `freeze`, `hidden`, `name`, and `showInTimeline` to that Sequence.
-- Pass `style` to the rendered element. With `layout="none"`, Studio discovers the outline automatically. Set the dimensions in the component because Element metadata does not pass them as props.
-- Render frame-dependent animation in a child below the Sequence. This makes [`useCurrentFrame()`](/docs/use-current-frame) respect `from`, `trimBefore`, `durationInFrames`, `playbackRate`, `loop`, and `freeze`. If the component that returns the Sequence calls it, it reads the parent clock.
+If the Element accepts a `style` prop and applies it to its visual root, use `wrapInSequence: {cropping: true}` to also expose crop controls. If it needs premounting, effects, cropping elsewhere, or custom timeline behavior, omit `wrapInSequence` and use the [manual wrapping pattern](/docs/studio/make-component-interactive#manual-wrapping).
-Export the schema-enabled component directly, without a forwarding wrapper. See the [oscilloscope](/elements/audio/oscilloscope), [waveform progress](/elements/audio/waveform-progress), and [mirrored spectrum](/elements/audio/mirrored-spectrum) Elements.
+When `wrapInSequence` is enabled:
-Check in Studio that the exported instance appears as one layer and can be moved and trimmed. Do not use `component-owned-sequence` only to remove markup. Do not add padding only for a gallery preview.
+- `Interactive.withSchema()` adds [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema), the timing props and a `<Sequence layout="none">` automatically.
+- The cropping configuration also adds [`Interactive.cropSchema`](/docs/interactive#interactivecropschema) and merges the crop style into the `style` passed to the component.
+- Pass `style` to the rendered element. Studio discovers its outline automatically. Set the dimensions in the component because Element metadata does not pass them as props.
+- Frame-dependent animation inside the component respects `from`, `trimBefore`, `durationInFrames`, `playbackRate`, `loop`, and `freeze` because the generated Sequence is outside it.
+- If the inner component accepts a React ref, refs passed to the exported component are forwarded directly to it.
+
+Export the schema-enabled component directly, without another forwarding wrapper.
+
+Check in Studio that the exported instance appears as one layer and can be trimmed. If it includes `Interactive.transformSchema`, also check that it can be moved. Do not use `component-owned-sequence` only to remove markup. Do not add padding only for a gallery preview.
## Initial props
diff --git a/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx b/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
index 7fd8a0cbfb..cb52373081 100644
--- a/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
+++ b/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
@@ -12,30 +12,25 @@ import React, {
import {
Easing,
Interactive,
- Sequence,
interpolate,
useBufferState,
useCurrentFrame,
useDelayRender,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type MapFlyoverLayerProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly destination?: readonly [number, number];
- readonly destinationLabel?: string;
- readonly lineWidth?: number;
- readonly origin?: readonly [number, number];
- readonly originLabel?: string;
- readonly routeColor?: string;
- };
+type MapFlyoverLayerProps = InteractiveTransformProps & {
+ readonly destination?: readonly [number, number];
+ readonly destinationLabel?: string;
+ readonly lineWidth?: number;
+ readonly origin?: readonly [number, number];
+ readonly originLabel?: string;
+ readonly routeColor?: string;
+};
const mapFlyoverSchema = {
- ...Interactive.baseSchema,
origin: {
type: 'array',
item: {type: 'number', step: 0.0001},
@@ -603,43 +598,32 @@ const MapFlyoverContent: React.FC<{
);
};
-const MapFlyoverLayerInner: React.FC<
- MapFlyoverLayerProps & {readonly controls: SequenceControls | undefined}
-> = ({
- controls,
+const MapFlyoverLayerInner: React.FC<MapFlyoverLayerProps> = ({
destination = [139.6917, 35.6895],
destinationLabel = 'Tokyo',
lineWidth = 24,
- name,
origin = [-0.1276, 51.5072],
originLabel = 'London',
routeColor = '#ff5c4d',
style,
- ...sequenceProps
}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'A-to-B Map Flyover'}
- >
- <MapFlyoverContent
- destination={destination}
- destinationLabel={destinationLabel}
- lineWidth={lineWidth}
- origin={origin}
- originLabel={originLabel}
- routeColor={routeColor}
- style={style ?? null}
- />
- </Sequence>
+ <MapFlyoverContent
+ destination={destination}
+ destinationLabel={destinationLabel}
+ lineWidth={lineWidth}
+ origin={origin}
+ originLabel={originLabel}
+ routeColor={routeColor}
+ style={style ?? null}
+ />
);
};
export const MapFlyover = Interactive.withSchema({
Component: MapFlyoverLayerInner,
componentName: '<MapFlyover>',
+ defaultSequenceName: 'A-to-B Map Flyover',
schema: mapFlyoverSchema,
- supportsEffects: false,
-}) as React.FC<MapFlyoverLayerProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx b/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
index dfe48f1595..1e1ebb29ad 100644
--- a/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
+++ b/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
@@ -4,15 +4,12 @@ import {
Easing,
Img,
Interactive,
- Sequence,
interpolate,
spring,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
loadFont('normal', {
@@ -26,18 +23,16 @@ const TILE_BASE_URL =
type Coordinates = readonly [longitude: number, latitude: number];
-type WatercolorMapProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly destination?: Coordinates;
- readonly destinationLabel?: string;
- readonly origin?: Coordinates;
- readonly originLabel?: string;
- readonly routeColor?: string;
- readonly routeWidth?: number;
- };
+type WatercolorMapProps = InteractiveTransformProps & {
+ readonly destination?: Coordinates;
+ readonly destinationLabel?: string;
+ readonly origin?: Coordinates;
+ readonly originLabel?: string;
+ readonly routeColor?: string;
+ readonly routeWidth?: number;
+};
const watercolorMapSchema = {
- ...Interactive.baseSchema,
origin: {
type: 'array',
item: {type: 'number', step: 0.0001},
@@ -402,43 +397,32 @@ const WatercolorMapContent: React.FC<{
);
};
-const WatercolorMapInner: React.FC<
- WatercolorMapProps & {readonly controls: SequenceControls | undefined}
-> = ({
- controls,
+const WatercolorMapInner: React.FC<WatercolorMapProps> = ({
destination = [8.5417, 47.3769],
destinationLabel = 'Zurich',
- name,
origin = [-118.2437, 34.0522],
originLabel = 'Los Angeles',
routeColor = '#ff0041',
routeWidth = 18,
style,
- ...sequenceProps
}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Watercolor map'}
- >
- <WatercolorMapContent
- destination={destination}
- destinationLabel={destinationLabel}
- origin={origin}
- originLabel={originLabel}
- routeColor={routeColor}
- routeWidth={routeWidth}
- style={style}
- />
- </Sequence>
+ <WatercolorMapContent
+ destination={destination}
+ destinationLabel={destinationLabel}
+ origin={origin}
+ originLabel={originLabel}
+ routeColor={routeColor}
+ routeWidth={routeWidth}
+ style={style}
+ />
);
};
export const WatercolorMap = Interactive.withSchema({
Component: WatercolorMapInner,
componentName: '<WatercolorMap>',
+ defaultSequenceName: 'Watercolor map',
schema: watercolorMapSchema,
- supportsEffects: false,
-}) as React.FC<WatercolorMapProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx b/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx
index c54b7591d9..fb3e76edfc 100644
--- a/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx
+++ b/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx
@@ -2,20 +2,15 @@ import React from 'react';
import {
CanvasImage,
Interactive,
- Sequence,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type SocialSafeZonesProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly platform?: 'instagram' | 'tiktok';
- };
+type SocialSafeZonesProps = InteractiveTransformProps & {
+ readonly platform?: 'instagram' | 'tiktok';
+};
const socialSafeZonesSchema = {
- ...Interactive.baseSchema,
platform: {
type: 'enum',
default: 'instagram',
@@ -29,72 +24,65 @@ const socialSafeZonesSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const SocialSafeZonesInner: React.FC<
- SocialSafeZonesProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({controls, name, platform = 'instagram', style, ...sequenceProps}) => {
+const SocialSafeZonesInner: React.FC<SocialSafeZonesProps> = ({
+ platform = 'instagram',
+ style,
+}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Social Safe Zones'}
+ <div
+ style={{
+ ...style,
+ height: 1920,
+ left: 0,
+ pointerEvents: 'none',
+ position: 'absolute',
+ top: 0,
+ width: 1080,
+ zIndex: 2147483647,
+ }}
>
- <div
+ <CanvasImage
+ aria-hidden="true"
+ fit="cover"
+ height={1920}
+ name="Background"
+ src="https://remotion.media/elements/commerce-tear-a-graphic.png"
+ style={{
+ height: '100%',
+ left: 0,
+ position: 'absolute',
+ top: 0,
+ width: '100%',
+ }}
+ width={1080}
+ />
+ <CanvasImage
+ aria-hidden="true"
+ fit="contain"
+ height={1920}
+ showInTimeline={false}
+ src={
+ platform === 'tiktok'
+ ? 'https://remotion.media/elements/social-safe-zones/tiktok-interface.png'
+ : 'https://remotion.media/elements/social-safe-zones/instagram-reels-interface-v3.png'
+ }
style={{
- ...style,
- height: 1920,
+ height: '100%',
left: 0,
- pointerEvents: 'none',
position: 'absolute',
top: 0,
- width: 1080,
- zIndex: 2147483647,
+ width: '100%',
}}
- >
- <CanvasImage
- aria-hidden="true"
- fit="cover"
- height={1920}
- name="Background"
- src="https://remotion.media/elements/commerce-tear-a-graphic.png"
- style={{
- height: '100%',
- left: 0,
- position: 'absolute',
- top: 0,
- width: '100%',
- }}
- width={1080}
- />
- <CanvasImage
- aria-hidden="true"
- fit="contain"
- height={1920}
- showInTimeline={false}
- src={
- platform === 'tiktok'
- ? 'https://remotion.media/elements/social-safe-zones/tiktok-interface.png'
- : 'https://remotion.media/elements/social-safe-zones/instagram-reels-interface-v3.png'
- }
- style={{
- height: '100%',
- left: 0,
- position: 'absolute',
- top: 0,
- width: '100%',
- }}
- width={1080}
- />
- </div>
- </Sequence>
+ width={1080}
+ />
+ </div>
);
};
export const SocialSafeZones = Interactive.withSchema({
Component: SocialSafeZonesInner,
componentName: '<SocialSafeZones>',
+ defaultSequenceName: 'Social Safe Zones',
schema: socialSafeZonesSchema,
- supportsEffects: false,
-}) as React.FC<SocialSafeZonesProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx b/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
index b0bb738d4b..b1d6102684 100644
--- a/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
+++ b/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
@@ -2,7 +2,6 @@ import {loadFont} from '@remotion/google-fonts/MonaSans';
import React from 'react';
import {
Interactive,
- Sequence,
interpolate,
spring,
useCurrentFrame,
@@ -10,7 +9,6 @@ import {
type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
loadFont('normal', {
@@ -18,17 +16,17 @@ loadFont('normal', {
subsets: ['latin'],
});
-type SpinningTextWheelProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly items?: string;
- };
+type SpinningTextWheelOwnProps = InteractiveTransformProps & {
+ readonly items?: string;
+};
+
+type SpinningTextWheelProps = InteractiveBaseProps & SpinningTextWheelOwnProps;
-type InteractiveSpinningTextWheelProps = SpinningTextWheelProps & {
+type InteractiveSpinningTextWheelProps = SpinningTextWheelOwnProps & {
readonly callerStyle: React.CSSProperties | null;
};
const spinningTextWheelSchema = {
- ...Interactive.baseSchema,
items: {
type: 'text-content',
default: 'Friday\nSaturday\nSunday\nMonday\nTuesday\nWednesday\nThursday',
@@ -39,17 +37,10 @@ const spinningTextWheelSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const SpinningTextWheelInner: React.FC<
- InteractiveSpinningTextWheelProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const SpinningTextWheelInner: React.FC<InteractiveSpinningTextWheelProps> = ({
callerStyle,
- controls,
items = 'Friday\nSaturday\nSunday\nMonday\nTuesday\nWednesday\nThursday',
- name,
style,
- ...sequenceProps
}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
@@ -81,83 +72,76 @@ const SpinningTextWheelInner: React.FC<
} = callerStyle ?? {};
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? '<SpinningTextWheel>'}
+ <div
+ style={{
+ rotate: callerRotate,
+ scale: callerScale,
+ transform: callerTransform,
+ transformBox: callerTransformBox,
+ transformOrigin: callerTransformOrigin,
+ transformStyle: callerTransformStyle,
+ translate: callerTranslate,
+ }}
>
<div
style={{
- rotate: callerRotate,
- scale: callerScale,
- transform: callerTransform,
- transformBox: callerTransformBox,
- transformOrigin: callerTransformOrigin,
- transformStyle: callerTransformStyle,
- translate: callerTranslate,
+ height: 200,
+ maskImage:
+ 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
+ overflow: 'hidden',
+ WebkitMaskImage:
+ 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
+ perspective: 10000,
+ position: 'relative',
+ width: 400,
+ ...style,
+ ...callerContentStyle,
}}
>
- <div
- style={{
- height: 200,
- maskImage:
- 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
- overflow: 'hidden',
- WebkitMaskImage:
- 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
- perspective: 10000,
- position: 'relative',
- width: 400,
- ...style,
- ...callerContentStyle,
- }}
- >
- {values.map((value, index) => {
- const wheelIndex = index / values.length + rotation;
- const angle = wheelIndex * Math.PI * 2;
- const rotateX = wheelIndex * 360;
+ {values.map((value, index) => {
+ const wheelIndex = index / values.length + rotation;
+ const angle = wheelIndex * Math.PI * 2;
+ const rotateX = wheelIndex * 360;
- return (
+ return (
+ <div
+ key={`${index}-${value}`}
+ style={{
+ alignItems: 'center',
+ backfaceVisibility: 'hidden',
+ display: 'flex',
+ height: '100%',
+ justifyContent: 'center',
+ left: 0,
+ opacity:
+ index === 0
+ ? interpolate(progress, [0.88, 1], [0.28, 1], {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ })
+ : 0.28,
+ position: 'absolute',
+ top: 0,
+ perspective: 1000,
+ transform: `translateZ(${Math.cos(angle) * 100}px) translateY(${Math.sin(angle) * 100}px) rotateX(${rotateX}deg)`,
+ width: '100%',
+ }}
+ >
<div
- key={`${index}-${value}`}
style={{
- alignItems: 'center',
backfaceVisibility: 'hidden',
- display: 'flex',
- height: '100%',
- justifyContent: 'center',
- left: 0,
- opacity:
- index === 0
- ? interpolate(progress, [0.88, 1], [0.28, 1], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- })
- : 0.28,
- position: 'absolute',
- top: 0,
- perspective: 1000,
- transform: `translateZ(${Math.cos(angle) * 100}px) translateY(${Math.sin(angle) * 100}px) rotateX(${rotateX}deg)`,
+ textAlign: 'center',
+ transform: `rotateX(${-rotateX}deg)`,
width: '100%',
}}
>
- <div
- style={{
- backfaceVisibility: 'hidden',
- textAlign: 'center',
- transform: `rotateX(${-rotateX}deg)`,
- width: '100%',
- }}
- >
- {value}
- </div>
+ {value}
</div>
- );
- })}
- </div>
+ </div>
+ );
+ })}
</div>
- </Sequence>
+ </div>
);
};
@@ -165,8 +149,8 @@ const InteractiveSpinningTextWheel = Interactive.withSchema({
Component: SpinningTextWheelInner,
componentName: '<SpinningTextWheel>',
schema: spinningTextWheelSchema,
- supportsEffects: false,
-}) as React.FC<InteractiveSpinningTextWheelProps>;
+ wrapInSequence: true,
+});
export const SpinningTextWheel: React.FC<SpinningTextWheelProps> = ({
style,
diff --git a/packages/example/src/mirrored-spectrum.element.tsx b/packages/example/src/mirrored-spectrum.element.tsx
index 4e523d6358..1e974a7513 100644
--- a/packages/example/src/mirrored-spectrum.element.tsx
+++ b/packages/example/src/mirrored-spectrum.element.tsx
@@ -3,25 +3,20 @@ import {useWindowedAudioData, visualizeAudio} from '@remotion/media-utils';
import React from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type MirroredAudioSpectrumProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly audioSrc?: string;
- readonly barColor?: string;
- readonly numberOfBars?: number;
- readonly sensitivity?: number;
- };
+type MirroredAudioSpectrumProps = InteractiveTransformProps & {
+ readonly audioSrc?: string;
+ readonly barColor?: string;
+ readonly numberOfBars?: number;
+ readonly sensitivity?: number;
+};
const mirroredAudioSpectrumSchema = {
- ...Interactive.baseSchema,
audioSrc: {
type: 'asset',
assetType: 'audio',
@@ -125,39 +120,28 @@ const MirroredAudioSpectrumContent: React.FC<{
);
};
-const MirroredAudioSpectrumInner: React.FC<
- MirroredAudioSpectrumProps & {readonly controls: SequenceControls | undefined}
-> = ({
+const MirroredAudioSpectrumInner: React.FC<MirroredAudioSpectrumProps> = ({
audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
barColor = '#0b84f3',
- controls,
- name,
numberOfBars = 65,
sensitivity = 1.5,
style,
- ...sequenceProps
}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Mirrored audio spectrum'}
- >
- <MirroredAudioSpectrumContent
- audioSrc={audioSrc}
- barColor={barColor}
- numberOfBars={numberOfBars}
- sensitivity={sensitivity}
- style={style}
- />
- </Sequence>
+ <MirroredAudioSpectrumContent
+ audioSrc={audioSrc}
+ barColor={barColor}
+ numberOfBars={numberOfBars}
+ sensitivity={sensitivity}
+ style={style}
+ />
);
};
export const MirroredAudioSpectrum = Interactive.withSchema({
Component: MirroredAudioSpectrumInner,
componentName: '<MirroredAudioSpectrum>',
+ defaultSequenceName: 'Mirrored audio spectrum',
schema: mirroredAudioSpectrumSchema,
- supportsEffects: false,
-}) as React.FC<MirroredAudioSpectrumProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/example/src/moving-pill-captions.element.tsx b/packages/example/src/moving-pill-captions.element.tsx
index 30503ce70a..6d1a35e326 100644
--- a/packages/example/src/moving-pill-captions.element.tsx
+++ b/packages/example/src/moving-pill-captions.element.tsx
@@ -13,19 +13,15 @@ import {
cancelRender,
Interactive,
interpolate,
- Sequence,
spring,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
type SequenceProps,
} from 'remotion';
-type MovingPillCaptionsProps = InteractiveBaseProps &
- InteractiveTransformProps &
+type MovingPillCaptionsProps = InteractiveTransformProps &
Pick<SequenceProps, 'width' | 'height'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds?: number;
@@ -45,7 +41,6 @@ const defaultWidth = 682;
const defaultHeight = 252;
const movingPillCaptionsSchema = {
- ...Interactive.baseSchema,
...Interactive.captionsSchema,
width: {
type: 'number',
@@ -377,19 +372,12 @@ const MovingPillCaptionsContent: React.FC<{
);
};
-const MovingPillCaptionsInner: React.FC<
- MovingPillCaptionsProps & {
- readonly controls: SequenceControls | undefined;
- }
-> = ({
+const MovingPillCaptionsInner: React.FC<MovingPillCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
height = defaultHeight,
- name,
style,
width = defaultWidth,
- ...interactiveProps
}) => {
const [fontLoaded, setFontLoaded] = useState(false);
@@ -404,28 +392,21 @@ const MovingPillCaptionsInner: React.FC<
}, []);
return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<MovingPillCaptions>'}
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <MovingPillCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- />
- </div>
- </Sequence>
+ <MovingPillCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ />
+ </div>
);
};
@@ -433,7 +414,7 @@ const MovingPillCaptionsLayer = Interactive.withSchema({
Component: MovingPillCaptionsInner,
componentName: '<MovingPillCaptions>',
schema: movingPillCaptionsSchema,
- supportsEffects: false,
-}) as React.FC<MovingPillCaptionsProps>;
+ wrapInSequence: true,
+});
export const MovingPillCaptions = MovingPillCaptionsLayer;
diff --git a/packages/example/src/oscilloscope.element.tsx b/packages/example/src/oscilloscope.element.tsx
index ac8aecb2f6..a65487622f 100644
--- a/packages/example/src/oscilloscope.element.tsx
+++ b/packages/example/src/oscilloscope.element.tsx
@@ -7,26 +7,21 @@ import {
import React from 'react';
import {
Interactive,
- Sequence,
useCurrentFrame,
useVideoConfig,
- type InteractiveBaseProps,
type InteractiveTransformProps,
type InteractivitySchema,
- type SequenceControls,
} from 'remotion';
-type AudioOscilloscopeProps = InteractiveBaseProps &
- InteractiveTransformProps & {
- readonly amplitude?: number;
- readonly audioSrc?: string;
- readonly lineColor?: string;
- readonly lineWidth?: number;
- readonly windowInSeconds?: number;
- };
+type AudioOscilloscopeProps = InteractiveTransformProps & {
+ readonly amplitude?: number;
+ readonly audioSrc?: string;
+ readonly lineColor?: string;
+ readonly lineWidth?: number;
+ readonly windowInSeconds?: number;
+};
const audioOscilloscopeSchema = {
- ...Interactive.baseSchema,
audioSrc: {
type: 'asset',
assetType: 'audio',
@@ -141,41 +136,30 @@ const AudioOscilloscopeContent: React.FC<{
);
};
-const AudioOscilloscopeInner: React.FC<
- AudioOscilloscopeProps & {readonly controls: SequenceControls | undefined}
-> = ({
+const AudioOscilloscopeInner: React.FC<AudioOscilloscopeProps> = ({
amplitude = 2,
audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- controls,
lineColor = '#55e6ff',
lineWidth = 6,
- name,
style,
windowInSeconds = 0.35,
- ...sequenceProps
}) => {
return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Audio oscilloscope'}
- >
- <AudioOscilloscopeContent
- amplitude={amplitude}
- audioSrc={audioSrc}
- lineColor={lineColor}
- lineWidth={lineWidth}
- style={style}
- windowInSeconds={windowInSeconds}
- />
- </Sequence>
+ <AudioOscilloscopeContent
+ amplitude={amplitude}
+ audioSrc={audioSrc}
+ lineColor={lineColor}
+ lineWidth={lineWidth}
+ style={style}
+ windowInSeconds={windowInSeconds}
+ />
);
};
export const AudioOscilloscope = Interactive.withSchema({
Component: AudioOscilloscopeInner,
componentName: '<AudioOscilloscope>',
+ defaultSequenceName: 'Audio oscilloscope',
schema: audioOscilloscopeSchema,
- supportsEffects: false,
-}) as React.FC<AudioOscilloscopeProps>;
+ wrapInSequence: true,
+});
diff --git a/packages/skills/skills/remotion-interactivity/SKILL.md b/packages/skills/skills/remotion-interactivity/SKILL.md
index 07c00c7d53..360685842f 100644
--- a/packages/skills/skills/remotion-interactivity/SKILL.md
+++ b/packages/skills/skills/remotion-interactivity/SKILL.md
@@ -305,7 +305,17 @@ Render separate elements if one version should have effects and another should n
## Making your own component interactive
-When using `Interactive.withSchema()`, include `Interactive.baseSchema` in the schema so standard timeline controls such as trimming, looping and visibility remain available, and forward `from`, `durationInFrames`, `trimBefore`, `trimAfter`, `playbackRate`, `loop`, `freeze`, `hidden`, `name` and `showInTimeline` to the `<Sequence>` the component renders.
+When using `Interactive.withSchema()`, set `wrapInSequence: true`. This adds `Interactive.baseSchema`, wraps the component in `<Sequence layout="none">` and exposes standard timeline controls such as trimming, looping and visibility.
+
+Use `defaultDurationInFrames` when the generated Sequence needs a default duration, and `defaultSequenceName` when its friendly default timeline label should differ from `componentName`.
+
+To also expose crop controls, set `wrapInSequence: {cropping: true}`. This adds `Interactive.cropSchema` and crop props automatically. The component must accept a `style` prop and apply it to its visual root. The generated Sequence remains `layout="none"`; the wrapper merges the crop style into the component's `style`.
+
+If the wrapped component accepts a React ref, automatic wrapping forwards refs directly to it.
+
+Omit `wrapInSequence` only when the component needs to render its own `<Sequence>` for advanced behavior such as premounting, effects, cropping that cannot be applied to the visual root or custom timeline behavior. In that case, include `Interactive.baseSchema`; forward `durationInFrames`, `from`, `trimBefore`, `playbackRate`, `loop`, `freeze`, `hidden`, `name`, `showInTimeline` and the injected `controls` prop to the `<Sequence>`; and set `supportsEffects` to `true` or `false` in the `Interactive.withSchema()` options.
+
+For manual premounting, also include `Interactive.premountSchema`, accept `InteractivePremountProps` and forward those props to the Sequence. For manual cropping on an absolute-fill Sequence, include `Interactive.cropSchema`, accept `InteractiveCropProps` and forward the crop props to the Sequence.
To make a custom userland component interactive, use:
[Make a component interactive](https://www.remotion.dev/docs/studio/make-component-interactive.md)