scale-swap-transition — Claude Code rule
The scale-swap-transition rule describes a morph-like swap between two DOM elements using a shrinking exit and a springy entrance. Use it for UI state changes.
AGPL-3.0 ★ 78,316 updated 2026-10-24
.claude/rules/scale-swap-transition.mdWhat scale-swap-transition does
The rule defines a morph-like replacement for two DOM elements without SVG path interpolation. The outgoing element shrinks and fades, while the incoming one grows from the same scale anchor with a spring overshoot. A short overlap keeps the handoff from looking like a hard cut.
Its example combines an HTML card structure, CSS for stacking and shared transform origin, and a GSAP timeline. Inner text appears after the new card settles, while a brand line can fade in before the swap. The pattern also covers a three-state A→B→C sequence and a flatter opacity-and-color variant.
The timeline version requires GSAP, since its animation sequence is built with gsap.timeline. The rule is about coordinated DOM transitions, not SVG shape interpolation.
What it helps with
- replace one card with another without a hard cut
- coordinate the exit and entrance scales
- reveal a subline after the new card settles
- chain an A→B→C state sequence
- swap same-shaped states with opacity and color
Example prompts for the agent
- Implement a
scale-swap-transitionbetween#outgoingand#incoming. - Create the GSAP timeline and reveal
#subafter the incoming card settles. - Adapt the pattern for an A→B→C cycle with overlapping transitions.
How to install scale-swap-transition
Manually: put the files in place
.claude/rules/scale-swap-transition.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/scale-swap-transition.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/scale-swap-transition.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/scale-swap-transition.mdManually: put the files in place
.clinerules/scale-swap-transition.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about scale-swap-transition
How do I install scale-swap-transition in Claude Code?
Create the rule file at .claude/rules/scale-swap-transition.md and place its contents there.
What does scale-swap-transition do?
It describes a DOM-element swap where the outgoing element shrinks and fades while the incoming element grows in with a spring effect.
Which platforms support scale-swap-transition?
The rule targets Claude Code and Codex. Its animation example uses GSAP.