Skip to content

🎥 Make videos programmatically with React

Remove height prop from caption elements

JonnyBurgerd1a149ee90a4
diff --git a/packages/codemods/src/basic-captions-element-source.ts b/packages/codemods/src/basic-captions-element-source.ts
index 04d26f1ac7..f1ba039cb0 100644
--- a/packages/codemods/src/basic-captions-element-source.ts
+++ b/packages/codemods/src/basic-captions-element-source.ts
@@ -13,7 +13,7 @@ import {
} from 'remotion';
type BasicCaptionsProps = InteractiveTransformProps &
- Pick<SequenceProps, 'width' | 'height'> & {
+ Pick<SequenceProps, 'width'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds?: number;
};
@@ -21,7 +21,6 @@ type BasicCaptionsProps = InteractiveTransformProps &
const BasicCaptionsContent: React.FC<BasicCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = 2000,
- height = 220,
style,
width = 900,
}) => {
@@ -53,7 +52,6 @@ const BasicCaptionsContent: React.FC<BasicCaptionsProps> = ({
left: '50%',
transform: 'translateX(-50%)',
width,
- height,
...style,
}}
>
@@ -93,14 +91,6 @@ const basicCaptionsSchema = {
description: 'Caption area width',
hiddenFromList: false,
},
- height: {
- type: 'number',
- min: 1,
- step: 1,
- default: undefined,
- description: 'Caption area height',
- hiddenFromList: false,
- },
combineTokensWithinMilliseconds: {
type: 'number',
min: 0,
diff --git a/packages/docs/elements/captions/basic-captions/basic-captions.tsx b/packages/docs/elements/captions/basic-captions/basic-captions.tsx
index 1d36ae7163..d2d918a8d4 100644
--- a/packages/docs/elements/captions/basic-captions/basic-captions.tsx
+++ b/packages/docs/elements/captions/basic-captions/basic-captions.tsx
@@ -11,14 +11,13 @@ import {
} from 'remotion';
type BasicCaptionsProps = InteractiveTransformProps &
- Pick<SequenceProps, 'width' | 'height'> & {
+ Pick<SequenceProps, 'width'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds?: number;
};
const defaultCombineTokensWithinMilliseconds = 2000;
const defaultWidth = 900;
-const defaultHeight = 220;
const basicCaptionsSchema = {
...Interactive.captionsSchema,
@@ -30,14 +29,6 @@ const basicCaptionsSchema = {
description: 'Caption area width',
hiddenFromList: false,
},
- height: {
- type: 'number',
- min: 1,
- step: 1,
- default: undefined,
- description: 'Caption area height',
- hiddenFromList: false,
- },
combineTokensWithinMilliseconds: {
type: 'number',
min: 0,
@@ -51,7 +42,6 @@ const basicCaptionsSchema = {
const BasicCaptionsContent: React.FC<BasicCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- height = defaultHeight,
style,
width = defaultWidth,
}) => {
@@ -78,9 +68,8 @@ const BasicCaptionsContent: React.FC<BasicCaptionsProps> = ({
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
- marginInline: 'auto',
width,
- height,
+ height: '100%',
...style,
}}
>
diff --git a/packages/docs/elements/captions/basic-captions/initial-props.ts b/packages/docs/elements/captions/basic-captions/initial-props.ts
index b12c353b88..57b950bd4f 100644
--- a/packages/docs/elements/captions/basic-captions/initial-props.ts
+++ b/packages/docs/elements/captions/basic-captions/initial-props.ts
@@ -29,5 +29,4 @@ export const basicCaptionsInitialProps = {
],
combineTokensWithinMilliseconds: 2000,
width: 900,
- height: 220,
} satisfies ComponentProps<typeof BasicCaptions>;
diff --git a/packages/docs/elements/captions/moving-pill-captions/initial-props.ts b/packages/docs/elements/captions/moving-pill-captions/initial-props.ts
index 37c815d646..64f772a781 100644
--- a/packages/docs/elements/captions/moving-pill-captions/initial-props.ts
+++ b/packages/docs/elements/captions/moving-pill-captions/initial-props.ts
@@ -55,5 +55,4 @@ export const movingPillCaptionsInitialProps = {
],
combineTokensWithinMilliseconds: 800,
width: 682,
- height: 252,
} satisfies ComponentProps<typeof MovingPillCaptions>;
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 f3f691f953..1af0ca39c6 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
@@ -22,7 +22,7 @@ import {
} from 'remotion';
type MovingPillCaptionsProps = InteractiveTransformProps &
- Pick<SequenceProps, 'width' | 'height'> & {
+ Pick<SequenceProps, 'width'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds?: number;
};
@@ -37,7 +37,6 @@ const pillBorderRadius = 10;
const pillMoveDurationInFrames = 5;
const defaultCombineTokensWithinMilliseconds = 800;
const defaultWidth = 682;
-const defaultHeight = 252;
const movingPillCaptionsSchema = {
...Interactive.captionsSchema,
@@ -49,14 +48,6 @@ const movingPillCaptionsSchema = {
description: 'Caption area width',
hiddenFromList: false,
},
- height: {
- type: 'number',
- min: 1,
- step: 1,
- default: undefined,
- description: 'Caption area height',
- hiddenFromList: false,
- },
combineTokensWithinMilliseconds: {
type: 'number',
min: 0,
@@ -321,7 +312,6 @@ const CaptionPage: React.FC<{
const MovingPillCaptionsContent: React.FC<MovingPillCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- height = defaultHeight,
style,
width = defaultWidth,
}) => {
@@ -354,8 +344,7 @@ const MovingPillCaptionsContent: React.FC<MovingPillCaptionsProps> = ({
return (
<div
style={{
- height,
- marginInline: 'auto',
+ height: '100%',
width,
...style,
}}
diff --git a/packages/docs/elements/captions/popping-word-captions/initial-props.ts b/packages/docs/elements/captions/popping-word-captions/initial-props.ts
index a7d5abb885..2c82926315 100644
--- a/packages/docs/elements/captions/popping-word-captions/initial-props.ts
+++ b/packages/docs/elements/captions/popping-word-captions/initial-props.ts
@@ -55,5 +55,4 @@ export const poppingWordCaptionsInitialProps = {
],
combineTokensWithinMilliseconds: 800,
width: 682,
- height: 252,
} satisfies ComponentProps<typeof PoppingWordCaptions>;
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 c9fc3293aa..e8a041a6c4 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
@@ -16,7 +16,7 @@ import {
} from 'remotion';
type PoppingWordCaptionsProps = InteractiveTransformProps &
- Pick<SequenceProps, 'width' | 'height'> & {
+ Pick<SequenceProps, 'width'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds?: number;
};
@@ -28,7 +28,6 @@ const highlightColor = '#2563eb';
const activeWordScale = 1.03;
const defaultCombineTokensWithinMilliseconds = 800;
const defaultWidth = 682;
-const defaultHeight = 252;
const poppingWordCaptionsSchema = {
...Interactive.captionsSchema,
@@ -40,14 +39,6 @@ const poppingWordCaptionsSchema = {
description: 'Caption area width',
hiddenFromList: false,
},
- height: {
- type: 'number',
- min: 1,
- step: 1,
- default: undefined,
- description: 'Caption area height',
- hiddenFromList: false,
- },
combineTokensWithinMilliseconds: {
type: 'number',
min: 0,
@@ -227,7 +218,6 @@ const CaptionPage: React.FC<{
const PoppingWordCaptionsContent: React.FC<PoppingWordCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- height = defaultHeight,
style,
width = defaultWidth,
}) => {
@@ -260,8 +250,7 @@ const PoppingWordCaptionsContent: React.FC<PoppingWordCaptionsProps> = ({
return (
<div
style={{
- height,
- marginInline: 'auto',
+ height: '100%',
width,
...style,
}}
diff --git a/packages/docs/elements/captions/rounded-captions/initial-props.ts b/packages/docs/elements/captions/rounded-captions/initial-props.ts
index a911b86604..7b1f2de84f 100644
--- a/packages/docs/elements/captions/rounded-captions/initial-props.ts
+++ b/packages/docs/elements/captions/rounded-captions/initial-props.ts
@@ -30,5 +30,4 @@ export const roundedCaptionsInitialProps = {
playbackRate: 1,
combineTokensWithinMilliseconds: 2000,
width: 900,
- height: 220,
} satisfies ComponentProps<typeof RoundedCaptions>;
diff --git a/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx b/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
index b57c9a2829..0570d35881 100644
--- a/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
+++ b/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
@@ -15,14 +15,13 @@ import {
} from 'remotion';
type RoundedCaptionsProps = InteractiveTransformProps &
- Pick<SequenceProps, 'width' | 'height'> & {
+ Pick<SequenceProps, 'width'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds: number | null;
};
const defaultCombineTokensWithinMilliseconds = 2000;
const defaultWidth = 900;
-const defaultHeight = 220;
const fontWeight = '700';
const maxFontSize = 64;
const lineHeight = 1.5;
@@ -39,14 +38,6 @@ const roundedCaptionsSchema = {
description: 'Caption area width',
hiddenFromList: false,
},
- height: {
- type: 'number',
- min: 1,
- step: 1,
- default: undefined,
- description: 'Caption area height',
- hiddenFromList: false,
- },
combineTokensWithinMilliseconds: {
type: 'number',
min: 0,
@@ -65,7 +56,6 @@ const {fontFamily, waitUntilDone} = loadFont('normal', {
const RoundedCaptionsContent: React.FC<RoundedCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds: providedCombineTokensWithinMilliseconds,
- height = defaultHeight,
style,
width = defaultWidth,
}) => {
@@ -114,7 +104,7 @@ const RoundedCaptionsContent: React.FC<RoundedCaptionsProps> = ({
maxBoxWidth: Math.max(1, width - horizontalPadding * 2),
fontFamily,
fontWeight,
- maxFontSize: Math.min(maxFontSize, height / (maxLines * lineHeight)),
+ maxFontSize,
validateFontIsLoaded: true,
}),
);
@@ -145,7 +135,7 @@ const RoundedCaptionsContent: React.FC<RoundedCaptionsProps> = ({
borderRadius,
}),
};
- }, [fontLoaded, height, page, width]);
+ }, [fontLoaded, page, width]);
return (
<div
@@ -153,9 +143,8 @@ const RoundedCaptionsContent: React.FC<RoundedCaptionsProps> = ({
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
- marginInline: 'auto',
width,
- height,
+ height: '100%',
...style,
}}
>
diff --git a/packages/docs/elements/captions/word-highlight-captions/initial-props.ts b/packages/docs/elements/captions/word-highlight-captions/initial-props.ts
index 6e567e8bd0..cb7b2afe59 100644
--- a/packages/docs/elements/captions/word-highlight-captions/initial-props.ts
+++ b/packages/docs/elements/captions/word-highlight-captions/initial-props.ts
@@ -55,5 +55,4 @@ export const wordHighlightCaptionsInitialProps = {
],
combineTokensWithinMilliseconds: 800,
width: 682,
- height: 252,
} satisfies ComponentProps<typeof WordHighlightCaptions>;
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 5682727b95..54a1280fba 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
@@ -14,7 +14,7 @@ import {
} from 'remotion';
type WordHighlightCaptionsProps = InteractiveTransformProps &
- Pick<SequenceProps, 'width' | 'height'> & {
+ Pick<SequenceProps, 'width'> & {
readonly captions: Caption[];
readonly combineTokensWithinMilliseconds?: number;
};
@@ -25,7 +25,6 @@ const textColor = '#ffffff';
const highlightColor = '#2563eb';
const defaultCombineTokensWithinMilliseconds = 800;
const defaultWidth = 682;
-const defaultHeight = 252;
const wordHighlightCaptionsSchema = {
...Interactive.captionsSchema,
@@ -37,14 +36,6 @@ const wordHighlightCaptionsSchema = {
description: 'Caption area width',
hiddenFromList: false,
},
- height: {
- type: 'number',
- min: 1,
- step: 1,
- default: undefined,
- description: 'Caption area height',
- hiddenFromList: false,
- },
combineTokensWithinMilliseconds: {
type: 'number',
min: 0,
@@ -186,7 +177,6 @@ const CaptionPage: React.FC<{
const WordHighlightCaptionsContent: React.FC<WordHighlightCaptionsProps> = ({
captions,
combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- height = defaultHeight,
style,
width = defaultWidth,
}) => {
@@ -219,8 +209,7 @@ const WordHighlightCaptionsContent: React.FC<WordHighlightCaptionsProps> = ({
return (
<div
style={{
- height,
- marginInline: 'auto',
+ height: '100%',
width,
...style,
}}