rendering-animate-svg-wrapper — Claude Code rule: setup guide
rendering-animate-svg-wrapper enforces wrapping svg elements in an outer div container for CSS animations. Enables GPU hardware acceleration across browsers.
MIT ★ 7,191 updated 2026-10-24
.claude/rules/rendering-animate-svg-wrapper.mdWhat rendering-animate-svg-wrapper does
Many browsers do not offer hardware acceleration when CSS keyframes or transitions run directly on an svg tag. This rule directs the agent to place animation classes on a parent div instead. The wrapper activates GPU acceleration.
The instruction covers all transforms and transitions, including transform, opacity, translate, scale, and rotate. Without a wrapper element, browsers fall back to CPU rasterization for vector animations, producing noticeable stuttering on animated icons.
What it helps with
- enable GPU acceleration for animated SVG components
- eliminate stuttering in rotating SVG spinners
- delegate transform transitions to an outer div wrapper
Example prompts for the agent
- Create a rotating spinner component in React
- Add a CSS pulse animation to this vector icon
How to install rendering-animate-svg-wrapper
Manually: put the files in place
.claude/rules/rendering-animate-svg-wrapper.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/rendering-animate-svg-wrapper.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/rendering-animate-svg-wrapper.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/rendering-animate-svg-wrapper.mdManually: put the files in place
.clinerules/rendering-animate-svg-wrapper.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about rendering-animate-svg-wrapper
How to install rendering-animate-svg-wrapper in Claude Code?
Save the rule file to .claude/rules/rendering-animate-svg-wrapper.md in your project repository.
What does rendering-animate-svg-wrapper do?
It directs Claude Code to wrap svg elements in an outer div and animate that container, enabling GPU acceleration.
Which CSS properties require an outer wrapper under this rule?
The rule applies to transitions and transforms using transform, opacity, translate, scale, and rotate.
Source text
rendering-animate-svg-wrapper.md · MIT
---
title: Animate SVG Wrapper Instead of SVG Element
impact: LOW
impactDescription: enables hardware acceleration
tags: rendering, svg, css, animation, performance
---
## Animate SVG Wrapper Instead of SVG Element
Many browsers don't have hardware acceleration for CSS3 animations on SVG elements. Wrap SVG in a `<div>` and animate the wrapper instead.
**Incorrect (animating SVG directly - no hardware acceleration):**
```tsx
function LoadingSpinner() {
return (
<svg
className="animate-spin"
width="24"
height="24"
viewBox="0 0 24 24"
>
<circle cx="12" cy="12" r="10" stroke="currentColor" />
</svg>
)
}
```
**Correct (animating wrapper div - hardware accelerated):**
```tsx
function LoadingSpinner() {
return (
<div className="animate-spin">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
>
<circle cx="12" cy="12" r="10" stroke="currentColor" />
</svg>
</div>
)
}
```
This applies to all CSS transforms and transitions (`transform`, `opacity`, `translate`, `scale`, `rotate`). The wrapper div allows browsers to use GPU acceleration for smoother animations.
© tech-leads-club · MIT · tech-leads-club/agent-skills