Remotion Rule: Measuring Dom Nodes
Remotion skill rule: Measuring DOM element dimensions in Remotion. Part of the official Remotion Agent Skill for programmatic video in React.
Installation agent prête
Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.
npx -y tokrepo@latest install eebf5616-36b0-4c9b-8ae3-64a46d81ae8c --target codexÀ exécuter après confirmation du plan en dry-run.
What it is
This is a Remotion skill rule that teaches AI coding assistants how to correctly measure DOM element dimensions inside Remotion video projects. Remotion applies a scale() CSS transform to the video container, which means raw getBoundingClientRect() values are inaccurate unless you divide by the current scale factor.
This rule is part of the official Remotion Agent Skill collection, designed for developers using Claude Code, Cursor, or OpenAI Codex to build programmatic videos in React.
How it saves time or tokens
Without this rule, an AI assistant will generate measurement code that uses getBoundingClientRect() directly, producing incorrect dimensions. Developers then spend time debugging why layout calculations are off by a fractional multiplier. The rule injects the correct pattern (dividing by useCurrentScale()) into the assistant's context automatically, eliminating a common source of visual bugs in Remotion projects.
How to use
- Install the Remotion skills collection:
npx skills add remotion-dev/skills
- The rule activates automatically when your AI assistant detects DOM measurement work in a Remotion project.
- When you need element dimensions, the assistant will generate code using
useCurrentScale()to compensate for the container transform.
Example
import { useCurrentScale } from 'remotion';
import { useRef, useEffect, useState } from 'react';
export const MeasuredComponent = () => {
const ref = useRef<HTMLDivElement>(null);
const scale = useCurrentScale();
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
useEffect(() => {
if (!ref.current) return;
const rect = ref.current.getBoundingClientRect();
setDimensions({
width: rect.width / scale,
height: rect.height / scale,
});
}, [scale]);
return (
<div ref={ref}>
<p>Width: {dimensions.width}px</p>
<p>Height: {dimensions.height}px</p>
</div>
);
};
Related on TokRepo
- Featured Workflows — Browse top-rated AI skills and workflows
- Automation Tools — Tools for automating development tasks
This tool integrates with standard development workflows and requires minimal configuration to get started. It is available as open-source software with documentation and community support through the official repository. The project follows semantic versioning for stable releases.
For teams evaluating this tool, the key advantage is reducing manual work in repetitive tasks. The automation provided by the built-in features means less custom code to maintain and fewer integration points to manage. This translates directly to lower maintenance costs and faster iteration cycles.
Common pitfalls
- Forgetting to divide by the scale factor is the most common mistake; raw
getBoundingClientRect()values will be scaled proportionally to the video container size. - The scale value changes when the preview window is resized, so always read it reactively via the
useCurrentScale()hook rather than caching a static value. - This rule only applies to Remotion projects; in standard React apps without a scale transform,
getBoundingClientRect()works as expected without correction.
Questions fréquentes
Remotion applies a scale() CSS transform to the video container to fit it into the preview window. This transform affects all values returned by getBoundingClientRect(), making them proportionally larger or smaller than the actual composition dimensions. Divide by useCurrentScale() to get correct values.
useCurrentScale() is a Remotion hook that returns the current scale factor applied to the video container. When the preview is at 50% zoom, it returns 0.5. Use this value to convert browser-reported dimensions back to composition-space coordinates.
Run npx skills add remotion-dev/skills to install the full Remotion skill collection. The measuring DOM nodes rule activates automatically when your AI assistant detects relevant code patterns in a Remotion project.
During final rendering (not preview), the scale is 1:1, so getBoundingClientRect returns accurate values. The correction via useCurrentScale() is still safe to use because the hook returns 1.0 during rendering, making the division a no-op.
The Remotion Agent Skill works with Claude Code, OpenAI Codex, and Cursor. Any tool that supports the skills protocol can load and activate these rules automatically during coding sessions.
Sources citées (3)
- Remotion Documentation— Remotion applies a scale() transform to the video container
- Remotion API Reference— useCurrentScale hook returns the preview scale factor
- Remotion Skills GitHub— Remotion Agent Skill is the official skill collection for AI coding assistants
En lien sur TokRepo
Source et remerciements
Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule:
measuring-dom-nodes
Part of the Remotion AI Skill collection on TokRepo.
Fil de discussion
Actifs similaires
Remotion Rule: Transparent Videos
Remotion skill rule: Rendering transparent videos in Remotion. Part of the official Remotion Agent Skill for programmatic video in React.
Remotion Rule: Get Video Dimensions
Remotion skill rule: Getting the width and height of a video file with Mediabunny. Part of the official Remotion Agent Skill for programmatic video in React.
Remotion Rule: Measuring Text
Remotion skill rule: Measuring text dimensions, fitting text to containers, and checking overflow. Part of the official Remotion Agent Skill for programmatic video in React.
Remotion Rule: Text Animations
Remotion skill rule: Typography and text animation patterns for Remotion.. Part of the official Remotion Agent Skill for programmatic video in React.