Skip to content

🎥 Make videos programmatically with React

Elements: Refine Social Safe Zones (#11290)

Igor Samokhovetsd958d0a190c9
diff --git a/packages/docs/elements/overlays/social-safe-zones/index.mdx b/packages/docs/elements/overlays/social-safe-zones/index.mdx
index 7fb292603c..e305afad1f 100644
--- a/packages/docs/elements/overlays/social-safe-zones/index.mdx
+++ b/packages/docs/elements/overlays/social-safe-zones/index.mdx
@@ -1,6 +1,6 @@
---
title: Social Safe Zones
-description: Capture-calibrated safe-area guides for TikTok and Instagram Reels.
+description: Preview TikTok and Instagram Reels interfaces to keep important content visible.
image: https://remotion.media/elements/overlays-social-safe-zones-preview.png
---
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 bf440f9c81..9789b995f0 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
@@ -1,4 +1,4 @@
-import React, {forwardRef, useId, useImperativeHandle, useRef} from 'react';
+import React, {forwardRef, useImperativeHandle, useRef} from 'react';
import {
CanvasImage,
Interactive,
@@ -11,9 +11,7 @@ import {
type SocialSafeZonesProps = InteractiveBaseProps &
InteractiveTransformProps & {
- readonly overlayOpacity?: number;
readonly platform?: 'instagram' | 'tiktok';
- readonly showInterface?: boolean;
};
const socialSafeZonesSchema = {
@@ -28,22 +26,6 @@ const socialSafeZonesSchema = {
tiktok: {},
},
},
- showInterface: {
- type: 'boolean',
- default: true,
- description: 'Show interface reference',
- keyframable: false,
- },
- overlayOpacity: {
- type: 'number',
- min: 0,
- max: 1,
- step: 0.05,
- default: 0.45,
- description: 'Unsafe area opacity',
- hiddenFromList: false,
- keyframable: false,
- },
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
@@ -52,128 +34,70 @@ const SocialSafeZonesInner = forwardRef<
SocialSafeZonesProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- controls,
- name,
- overlayOpacity = 0.45,
- platform = 'instagram',
- showInterface = true,
- style,
- ...sequenceProps
- },
- ref,
- ) => {
- const outlineRef = useRef<HTMLDivElement>(null);
- const maskId = `social-safe-zone-${useId().replaceAll(':', '')}`;
-
- useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);
+>(({controls, name, platform = 'instagram', style, ...sequenceProps}, ref) => {
+ const outlineRef = useRef<HTMLDivElement>(null);
- // Both paths and interface references are measured from representative
- // iOS captures of full-green videos, rather than inferred from platform
- // marketing material. Author-specific text and avatars were replaced in
- // the transparent interface images.
- //
- // TikTok: The 1290×2293 video region at y=139 in tiktok-layout.png was
- // mapped to 1080×1920. The path clears the search UI (ending at y=132),
- // the action rail (starting at x=949, y=803), and captions (y=1749).
- //
- // Instagram: The 1290×2550 Reels viewport in reels-layout.png displays a
- // 9:16 video with cover sizing. Mapping it back to 1080×1920 leaves the
- // visible source between x=54 and x=1026. The path clears the top controls
- // (ending at y=212), action rail (starting at x=927, y=1114), and captions
- // (y=1726).
- const safeAreaPath =
- platform === 'tiktok'
- ? 'M24 160 H1050 V780 H930 V1715 H24 Z'
- : 'M55 235 H1025 V1090 H900 V1700 H55 Z';
+ useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Social Safe Zones'}
- outlineRef={outlineRef}
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'Social Safe Zones'}
+ outlineRef={outlineRef}
+ >
+ <div
+ ref={outlineRef}
+ style={{
+ ...style,
+ height: 1920,
+ left: 0,
+ pointerEvents: 'none',
+ position: 'absolute',
+ top: 0,
+ width: 1080,
+ zIndex: 2147483647,
+ }}
>
- <div
- ref={outlineRef}
+ <CanvasImage
+ aria-hidden="true"
+ fit="cover"
+ height={1920}
+ name="Background"
+ src="https://remotion.media/elements/commerce-tear-a-graphic.png"
style={{
- ...style,
- height: 1920,
+ height: '100%',
left: 0,
- pointerEvents: 'none',
position: 'absolute',
top: 0,
- width: 1080,
- zIndex: 2147483647,
+ width: '100%',
}}
- >
- <svg
- aria-hidden="true"
- height="100%"
- preserveAspectRatio="xMidYMid meet"
- viewBox="0 0 1080 1920"
- width="100%"
- >
- <defs>
- <mask
- height="1920"
- id={maskId}
- maskUnits="userSpaceOnUse"
- width="1080"
- x="0"
- y="0"
- >
- <rect fill="white" height="1920" width="1080" />
- <path d={safeAreaPath} fill="black" />
- </mask>
- </defs>
-
- <rect
- fill="#ff3158"
- height="1920"
- mask={`url(#${maskId})`}
- opacity={overlayOpacity}
- width="1080"
- />
-
- <path
- d={safeAreaPath}
- fill="none"
- stroke="#c8ff3d"
- strokeDasharray="22 16"
- strokeWidth="8"
- />
- </svg>
-
- {showInterface ? (
- <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}
- />
- ) : null}
- </div>
- </Sequence>
- );
- },
-);
+ 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>
+ );
+});
export const SocialSafeZones = Interactive.withSchema({
Component: SocialSafeZonesInner,
diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.ts
index bebbf84835..574377fed9 100644
--- a/packages/docs/src/components/Elements/element-definitions.ts
+++ b/packages/docs/src/components/Elements/element-definitions.ts
@@ -784,7 +784,7 @@ const elementImplementations = [
component: SocialSafeZones,
contributors: [],
description:
- 'Capture-calibrated safe-area guides for TikTok and Instagram Reels.',
+ 'Preview TikTok and Instagram Reels interfaces to keep important content visible.',
dependencies: [],
durationInFrames: 120,
elementHeight: 1920,
@@ -800,7 +800,7 @@ const elementImplementations = [
'https://remotion.media/elements/overlays-social-safe-zones-preview.mp4',
},
safeArea: 0,
- initialProps: null,
+ initialProps: {platform: 'tiktok'},
installationMode: 'component-owned-sequence',
width: 1080,
},