# measuring-dom-nodes

The measuring-dom-nodes rule covers measuring DOM element sizes inside Remotion compositions without the video container's scale distorting the numbers.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 849 repo stars
- Author: coleam00
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/coleam00/second-brain-skills/tree/HEAD/.claude/skills/remotion/rules/measuring-dom-nodes.md
- Updated: 2026-01-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/measuring-dom-nodes

## What it does

Remotion wraps the video output in a CSS `scale()` transform, which throws off raw values from `getBoundingClientRect()`. The rule shows how to correct for that using the `useCurrentScale()` hook, dividing the measured width and height by the current scale factor.

The included snippet pairs a `ref`, `useEffect` and `useState` to recalculate an element's dimensions whenever the scale changes. Claude Code reaches for this pattern on layout code in Remotion projects.

Skip the scale correction and any measurement taken during a scaled render comes out wrong.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/measuring-dom-nodes.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/measuring-dom-nodes.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/measuring-dom-nodes.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/measuring-dom-nodes.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/measuring-dom-nodes.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/coleam00/second-brain-skills/tree/HEAD/.claude/skills/remotion/rules/measuring-dom-nodes.md

## When to use it
- get accurate width and height of a DOM node inside a Remotion composition
- account for container scale when measuring layout
- read dimensions from getBoundingClientRect without distortion
- build a component that re-measures a node on scale change

## Example prompts
- Add a measurement for this text block using getBoundingClientRect adjusted for the current scale
- Fix the width calculation in this Remotion composition so it doesn't break when the video is scaled
- Write a component that tracks a DOM node's dimensions with useCurrentScale

## Similar
- [expo-dom](https://affpapa.org/en/nevibecode/skills/expo-dom.md) — skill · 25700 installs
- [js-batch-dom-css](https://affpapa.org/en/nevibecode/rules/js-batch-dom-css.md) — rule · ★ 7191 repo stars
- [pixijs-scene-dom-container](https://affpapa.org/en/nevibecode/skills/pixijs-scene-dom-container.md) — skill · 6900 installs
- [inspecting-hermes-desktop-dom](https://affpapa.org/en/nevibecode/skills/inspecting-hermes-desktop-dom.md) — skill · 263 installs
- [hunt-dom](https://affpapa.org/en/nevibecode/skills/hunt-dom.md) — skill · ★ 16193 repo stars
- [page-tree](https://affpapa.org/en/nevibecode/skills/page-tree.md) — skill · 285 installs

From the same set: [coleam00/second-brain-skills](https://affpapa.org/en/nevibecode/by/coleam00/second-brain-skills.md) — 33 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
