Skip to main content
rule CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/rendering-animate-svg-wrapper.md
Open on GitHub

What 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.md

The paths frontmatter field limits the files

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set130

The whole set →
rerender-memo rerender-memo — a rule that guides your agent to extract expensive computations into memoized components, enabling early returns without triggering child logic. Speeds up React re-render paths. CX Codex +1 ★ 7,191repo stars bundle-preload bundle-preload directs the agent to preload heavy JavaScript chunks on user intent like hover or focus. This cuts perceived interface latency. CX Codex +1 ★ 7,191repo stars client-swr-dedup The client-swr-dedup rule recommends SWR to share requests between component instances and reuse cached data. It fits React projects that fetch data on the client. CX Codex +1 ★ 7,191repo stars rerender-memo-with-default-value rerender-memo-with-default-value — a rule that prevents memoization from breaking when React components have default values (functions, objects, arrays) in parameters. It instructs you to extract these defaults into module-level constants. CX Codex +1 ★ 7,191repo stars rerender-derived-state-no-effect The rerender-derived-state-no-effect rule keeps derived values out of React state and avoids effects that mirror props. Use it when reviewing components for extra renders and state drift. CX Codex +1 ★ 7,191repo stars rerender-move-effect-to-event rerender-move-effect-to-event tells the agent to fire a side effect from the handler that caused it, not from useEffect watching a state flag. CX Codex +1 ★ 7,191repo stars async-dependencies async-dependencies instructs Claude Code to execute partially dependent async tasks concurrently using better-all or native promise chains rather than blocking Promise.all calls. CX Codex +1 ★ 7,191repo stars server-cache-lru The server-cache-lru rule explains when React.cache() is too narrow and an LRU cache should share data between requests. Use it for sequential actions that reuse the same records. CX Codex +1 ★ 7,191repo stars

Project sponsors

Companies that keep this analytics open